From: Diane Trout Date: Fri, 22 Jan 2010 19:30:48 +0000 (+0000) Subject: Refine user handling. X-Git-Tag: 0.4.0~19 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=58eebc7b9a09e64e431d6e34d579561fbd70ce70 Refine user handling. The sysadmins need username to match up with the unix accounts, The site manager needs a meaningful name to attach users to samples. So the HTSUser string representation is first/last name and then username in the corner. In addition I modified the add user popup form to allow setting the first/last name during the user creation. --- diff --git a/htsworkflow/frontend/samples/admin.py b/htsworkflow/frontend/samples/admin.py index ef815a2..deb6159 100644 --- a/htsworkflow/frontend/samples/admin.py +++ b/htsworkflow/frontend/samples/admin.py @@ -64,7 +64,7 @@ class ExperimentTypeOptions(admin.ModelAdmin): class HTSUserCreationForm(UserCreationForm): class Meta: model = HTSUser - fields = ("username",) + fields = ("username",'first_name','last_name') class HTSUserChangeForm(UserChangeForm): class Meta: @@ -73,7 +73,6 @@ class HTSUserChangeForm(UserChangeForm): class HTSUserOptions(UserAdmin): form = HTSUserChangeForm add_form = HTSUserCreationForm - class LaneLibraryInline(admin.StackedInline): model = Lane diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index cda52a3..32d63a3 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -271,13 +271,14 @@ class HTSUser(User): #objects = UserManager() class Meta: - ordering = ['username'] + ordering = ['first_name', 'last_name', 'username'] def admin_url(self): return '/admin/%s/%s/%d' % (self._meta.app_label, self._meta.module_name, self.id) def __unicode__(self): - return unicode(self.username) + u" (" + unicode(self.get_full_name()) + u")" + #return unicode(self.username) + u" (" + unicode(self.get_full_name()) + u")" + return unicode(self.get_full_name()) + u' (' + unicode(self.username) + ')' def HTSUserInsertID(sender, instance, **kwargs): """ diff --git a/htsworkflow/frontend/templates/admin/auth/user/add_form.html b/htsworkflow/frontend/templates/admin/auth/user/add_form.html new file mode 100644 index 0000000..d3eaf3f --- /dev/null +++ b/htsworkflow/frontend/templates/admin/auth/user/add_form.html @@ -0,0 +1,47 @@ +{% extends "admin/change_form.html" %} +{% load i18n %} + +{% block after_field_sets %} + +

{% trans "First, enter a username and password. Then, you'll be able to edit more user options." %}

+ +
+ +
+ {{ form.username.errors }} + {# TODO: get required class on label_tag #} + {{ form.username }} +

{{ form.username.help_text }}

+
+ +
+ {{ form.first_name.errors }} + {{ form.last_name.errors }} + {# TODO: get required class on label_tag #} +
+ {{ form.first_name }} +

{{ form.first_name.help_text }}

+
+
+ {{ form.last_name }} +

{{ form.last_name.help_text }}

+
+
+ +
+ {{ form.password1.errors }} + {# TODO: get required class on label_tag #} + {{ form.password1 }} +
+ +
+ {{ form.password2.errors }} + {# TODO: get required class on label_tag #} + {{ form.password2 }} +

{% trans 'Enter the same password as above, for verification.' %}

+
+ + + +
+{% endblock %}