Refine user handling.
authorDiane Trout <diane@caltech.edu>
Fri, 22 Jan 2010 19:30:48 +0000 (19:30 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 22 Jan 2010 19:30:48 +0000 (19:30 +0000)
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.

htsworkflow/frontend/samples/admin.py
htsworkflow/frontend/samples/models.py
htsworkflow/frontend/templates/admin/auth/user/add_form.html [new file with mode: 0644]

index ef815a25cc34bb21086be003e8c317b3c94051bf..deb61593d49dfbb13508d77c634b3096bc02a564 100644 (file)
@@ -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
index cda52a308f994fe673dd65b73f4ad94b0bc8c1ea..32d63a35d545fafc9f2f78ca295364db266d11a3 100644 (file)
@@ -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 (file)
index 0000000..d3eaf3f
--- /dev/null
@@ -0,0 +1,47 @@
+{% extends "admin/change_form.html" %}
+{% load i18n %}
+
+{% block after_field_sets %}
+
+<p>{% trans "First, enter a username and password. Then, you'll be able to edit more user options." %}</p>
+
+<fieldset class="module aligned">
+
+<div class="form-row">
+  {{ form.username.errors }}
+  {# TODO: get required class on label_tag #}
+  <label for="id_username" class="required">{% trans 'Username' %}:</label> {{ form.username }}
+  <p class="help">{{ form.username.help_text }}</p>
+</div>
+
+<div class="form-row">
+  {{ form.first_name.errors }}
+  {{ form.last_name.errors }}
+ {# TODO: get required class on label_tag #}
+  <div class="field-box">
+  <label for="first_name" >{% trans 'First Name' %}:</label> {{ form.first_name }}
+  <p class="help">{{ form.first_name.help_text }}</p>
+  </div>  
+  <div class="field-box">
+  <label for="last_name" >{% trans 'Last Name' %}:</label> {{ form.last_name }}
+  <p class="help">{{ form.last_name.help_text }}</p>
+  </div>
+</div>
+
+<div class="form-row">
+  {{ form.password1.errors }}
+  {# TODO: get required class on label_tag #}
+  <label for="id_password1" class="required">{% trans 'Password' %}:</label> {{ form.password1 }}
+</div>
+
+<div class="form-row">
+  {{ form.password2.errors }}
+  {# TODO: get required class on label_tag #}
+  <label for="id_password2" class="required">{% trans 'Password (again)' %}:</label> {{ form.password2 }}
+  <p class="help">{% trans 'Enter the same password as above, for verification.' %}</p>
+</div>
+
+<script type="text/javascript">document.getElementById("id_username").focus();</script>
+
+</fieldset>
+{% endblock %}