Commit a4ed62bf9c6f9c434f65f9ad95476664364ee8af
1 parent
2d74ab9f
Exists in
master
and in
39 other branches
Better form rendering for user update
Showing
4 changed files
with
34 additions
and
9 deletions
Show diff stats
src/accounts/forms.py
| @@ -36,7 +36,7 @@ class UserCreationForm(UserForm): | @@ -36,7 +36,7 @@ class UserCreationForm(UserForm): | ||
| 36 | class UserUpdateForm(UserForm): | 36 | class UserUpdateForm(UserForm): |
| 37 | class Meta: | 37 | class Meta: |
| 38 | model = User | 38 | model = User |
| 39 | - fields = ('first_name', 'last_name', 'email', 'username', | 39 | + fields = ('username', 'first_name', 'last_name', 'email', |
| 40 | 'institution', 'role', 'twitter', 'facebook', | 40 | 'institution', 'role', 'twitter', 'facebook', |
| 41 | 'google_talk', 'webpage') | 41 | 'google_talk', 'webpage') |
| 42 | 42 |
src/accounts/templates/accounts/user_create_form.html
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | <legend>{% trans 'Personal Information' %}</legend> | 30 | <legend>{% trans 'Personal Information' %}</legend> |
| 31 | {% for field in user_form %} | 31 | {% for field in user_form %} |
| 32 | <div class="form-group{% if field.field.required %} required{% endif %}{% if field.errors %} alert alert-danger has-error{% endif %}"> | 32 | <div class="form-group{% if field.field.required %} required{% endif %}{% if field.errors %} alert alert-danger has-error{% endif %}"> |
| 33 | - <label for="first_name" class="control-label"> | 33 | + <label for="{{ field.name }}" class="control-label"> |
| 34 | {{ field.label }} | 34 | {{ field.label }} |
| 35 | </label> | 35 | </label> |
| 36 | {{ field }} | 36 | {{ field }} |
src/accounts/templates/accounts/user_update_form.html
| @@ -2,10 +2,35 @@ | @@ -2,10 +2,35 @@ | ||
| 2 | {% load i18n gravatar %} | 2 | {% load i18n gravatar %} |
| 3 | 3 | ||
| 4 | {% block main-content %} | 4 | {% block main-content %} |
| 5 | - <form method="post"> | ||
| 6 | - {% csrf_token %} | ||
| 7 | - {{ form.as_p }} | ||
| 8 | - | ||
| 9 | - <button type="submit" class="btn btn-primary">{% trans "Update" %}</button> | ||
| 10 | - </form> | 5 | + <form method="post"> |
| 6 | + {% csrf_token %} | ||
| 7 | + | ||
| 8 | + <div class="col-lg-12"> | ||
| 9 | + <a href="https://gravatar.com" target="_blank"> | ||
| 10 | + {% gravatar request.user.email 50 %} | ||
| 11 | + {% trans "Change your avatar at Gravatar.com" %} | ||
| 12 | + </a> | ||
| 13 | + </div> | ||
| 14 | + <br> | ||
| 15 | + | ||
| 16 | + <div class="row"> | ||
| 17 | + {% for field in form %} | ||
| 18 | + <div class="col-lg-4 col-md-6 col-sm-12 col-xm-12"> | ||
| 19 | + <div class="form-group{% if field.field.required %} required{% endif %}{% if field.errors %} alert alert-danger has-error{% endif %}"> | ||
| 20 | + <label for="{{ field.name }}" class="control-label"> | ||
| 21 | + {{ field.label }} | ||
| 22 | + </label> | ||
| 23 | + {{ field }} | ||
| 24 | + {{ field.errors }} | ||
| 25 | + </div> | ||
| 26 | + </div> | ||
| 27 | + {% endfor %} | ||
| 28 | + </div> | ||
| 29 | + | ||
| 30 | + <div class="row"> | ||
| 31 | + <div class="submit"> | ||
| 32 | + <button type="submit" class="btn btn-primary btn-lg btn-block">{% trans "Update" %}</button> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | + </form> | ||
| 11 | {% endblock %} | 36 | {% endblock %} |
src/colab/static/css/screen.css
| @@ -145,7 +145,7 @@ form.signup .form-group { | @@ -145,7 +145,7 @@ form.signup .form-group { | ||
| 145 | margin-left: 0.5em; | 145 | margin-left: 0.5em; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | -form.signup div.submit { | 148 | +div.submit { |
| 149 | margin: auto; | 149 | margin: auto; |
| 150 | margin-bottom: 5em; | 150 | margin-bottom: 5em; |
| 151 | width: 200px; | 151 | width: 200px; |