mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-27 01:39:03 +01:00
Add Django filesize template filter to fix createUser and modifyWebsite errors
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% load user_filters %}
|
||||
{% block title %}{% trans "Create New User - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
|
||||
0
userManagment/templatetags/__init__.py
Normal file
0
userManagment/templatetags/__init__.py
Normal file
21
userManagment/templatetags/user_filters.py
Normal file
21
userManagment/templatetags/user_filters.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Custom Django template filters for user management
|
||||
"""
|
||||
from django import template
|
||||
from django.template.defaultfilters import filesizeformat
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(name='filesize')
|
||||
def filesize_filter(value):
|
||||
"""
|
||||
Alias for Django's filesizeformat filter to maintain compatibility
|
||||
with templates that use |filesize instead of |filesizeformat
|
||||
"""
|
||||
if value is None:
|
||||
return '0 B'
|
||||
try:
|
||||
return filesizeformat(value)
|
||||
except (ValueError, TypeError):
|
||||
return '0 B'
|
||||
@@ -1,5 +1,6 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% load website_filters %}
|
||||
{% block title %}{% trans "Modify Website - CyberPanel" %}{% endblock %}
|
||||
|
||||
{% block header_scripts %}
|
||||
|
||||
0
websiteFunctions/templatetags/__init__.py
Normal file
0
websiteFunctions/templatetags/__init__.py
Normal file
21
websiteFunctions/templatetags/website_filters.py
Normal file
21
websiteFunctions/templatetags/website_filters.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Custom Django template filters for user management
|
||||
"""
|
||||
from django import template
|
||||
from django.template.defaultfilters import filesizeformat
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(name='filesize')
|
||||
def filesize_filter(value):
|
||||
"""
|
||||
Alias for Django's filesizeformat filter to maintain compatibility
|
||||
with templates that use |filesize instead of |filesizeformat
|
||||
"""
|
||||
if value is None:
|
||||
return '0 B'
|
||||
try:
|
||||
return filesizeformat(value)
|
||||
except (ValueError, TypeError):
|
||||
return '0 B'
|
||||
Reference in New Issue
Block a user