Fixed ftp traffic backend

This commit is contained in:
Marc Aymerich 2015-03-02 12:07:27 +00:00
parent 04ab19379e
commit 7c5165f753
4 changed files with 14 additions and 10 deletions

View File

@ -13,7 +13,8 @@ from . import settings
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."),
validators=[validators.RegexValidator(r'^[\w.-]+$',
_("Enter a valid username."), 'invalid')])

View File

@ -87,12 +87,12 @@ class ResourceAdmin(ExtendedModelAdmin):
class ResourceDataAdmin(ExtendedModelAdmin):
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'
)
list_filter = ('resource',)
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'
)
search_fields = ('object_id',)

View File

@ -36,10 +36,12 @@ class SystemUserBackend(ServiceController):
def delete(self, user):
context = self.get_context(user)
self.append("{ sleep 2 && killall -u %(username)s -s KILL; } &" % context)
self.append("killall -u %(username)s || true" % context)
self.append("userdel %(username)s || true" % context)
self.append("groupdel %(username)s || true" % context)
self.append(textwrap.dedent("""\
{ sleep 2 && killall -u %(username)s -s KILL; } &
killall -u %(username)s || true
userdel %(username)s || true
groupdel %(username)s || true""" % context
))
self.delete_home(context, user)
def grant_permission(self, user):
@ -131,10 +133,11 @@ class FTPTraffic(ServiceMonitor):
months["Nov"] = "11"
months["Dec"] = "12"
} {
# Fri Jul 11 13:23:17 2014
# Fri Jul 1 13:23:17 2014
split($4, time, ":")
day = sprintf("%02d", $3)
# 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) {
sum += $(NF-2)
}

View File

@ -24,7 +24,7 @@ class SystemUser(models.Model):
"""
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
username = models.CharField(_("username"), max_length=32, unique=True,