Fixed ftp traffic backend
This commit is contained in:
parent
04ab19379e
commit
7c5165f753
|
@ -13,7 +13,8 @@ from . import settings
|
||||||
|
|
||||||
|
|
||||||
class Account(auth.AbstractBaseUser):
|
class Account(auth.AbstractBaseUser):
|
||||||
username = models.CharField(_("username"), max_length=64, unique=True,
|
# Username max_length determined by LINUX system user lentgh: 32
|
||||||
|
username = models.CharField(_("username"), max_length=32, unique=True,
|
||||||
help_text=_("Required. 64 characters or fewer. Letters, digits and ./-/_ only."),
|
help_text=_("Required. 64 characters or fewer. Letters, digits and ./-/_ only."),
|
||||||
validators=[validators.RegexValidator(r'^[\w.-]+$',
|
validators=[validators.RegexValidator(r'^[\w.-]+$',
|
||||||
_("Enter a valid username."), 'invalid')])
|
_("Enter a valid username."), 'invalid')])
|
||||||
|
|
|
@ -87,12 +87,12 @@ class ResourceAdmin(ExtendedModelAdmin):
|
||||||
|
|
||||||
class ResourceDataAdmin(ExtendedModelAdmin):
|
class ResourceDataAdmin(ExtendedModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
'id', 'resource_link', 'content_object_link', 'display_used', 'allocated', 'display_unit',
|
'id', 'resource_link', 'content_object_link', 'allocated', 'display_used', 'display_unit',
|
||||||
'display_updated'
|
'display_updated'
|
||||||
)
|
)
|
||||||
list_filter = ('resource',)
|
list_filter = ('resource',)
|
||||||
fields = (
|
fields = (
|
||||||
'resource_link', 'content_type', 'content_object_link', 'display_used', 'display_updated',
|
'resource_link', 'content_type', 'content_object_link', 'display_updated', 'display_used',
|
||||||
'allocated', 'display_unit'
|
'allocated', 'display_unit'
|
||||||
)
|
)
|
||||||
search_fields = ('object_id',)
|
search_fields = ('object_id',)
|
||||||
|
|
|
@ -36,10 +36,12 @@ class SystemUserBackend(ServiceController):
|
||||||
|
|
||||||
def delete(self, user):
|
def delete(self, user):
|
||||||
context = self.get_context(user)
|
context = self.get_context(user)
|
||||||
self.append("{ sleep 2 && killall -u %(username)s -s KILL; } &" % context)
|
self.append(textwrap.dedent("""\
|
||||||
self.append("killall -u %(username)s || true" % context)
|
{ sleep 2 && killall -u %(username)s -s KILL; } &
|
||||||
self.append("userdel %(username)s || true" % context)
|
killall -u %(username)s || true
|
||||||
self.append("groupdel %(username)s || true" % context)
|
userdel %(username)s || true
|
||||||
|
groupdel %(username)s || true""" % context
|
||||||
|
))
|
||||||
self.delete_home(context, user)
|
self.delete_home(context, user)
|
||||||
|
|
||||||
def grant_permission(self, user):
|
def grant_permission(self, user):
|
||||||
|
@ -131,10 +133,11 @@ class FTPTraffic(ServiceMonitor):
|
||||||
months["Nov"] = "11"
|
months["Nov"] = "11"
|
||||||
months["Dec"] = "12"
|
months["Dec"] = "12"
|
||||||
} {
|
} {
|
||||||
# Fri Jul 11 13:23:17 2014
|
# Fri Jul 1 13:23:17 2014
|
||||||
split($4, time, ":")
|
split($4, time, ":")
|
||||||
|
day = sprintf("%02d", $3)
|
||||||
# line_date = year month day hour minute second
|
# line_date = year month day hour minute second
|
||||||
line_date = $5 months[$2] $3 time[1] time[2] time[3]
|
line_date = $5 months[$2] day time[1] time[2] time[3]
|
||||||
if ( line_date > ini && line_date < end) {
|
if ( line_date > ini && line_date < end) {
|
||||||
sum += $(NF-2)
|
sum += $(NF-2)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SystemUser(models.Model):
|
||||||
"""
|
"""
|
||||||
System users
|
System users
|
||||||
|
|
||||||
Username max_length determined by min(user, group) on common LINUX systems; min(32, 16)
|
Username max_length determined by LINUX system user lentgh: 32
|
||||||
"""
|
"""
|
||||||
# TODO max_length
|
# TODO max_length
|
||||||
username = models.CharField(_("username"), max_length=32, unique=True,
|
username = models.CharField(_("username"), max_length=32, unique=True,
|
||||||
|
|
Loading…
Reference in New Issue