diff options
author | Weitian LI <liweitianux@gmail.com> | 2014-04-27 02:00:01 +0800 |
---|---|---|
committer | Weitian LI <liweitianux@gmail.com> | 2014-04-27 02:00:01 +0800 |
commit | 9172b7f08a7dabde275253b47ad051600decbe7b (patch) | |
tree | 8a001b773cebb23821550d619170a28575f200fa | |
parent | c4d4764da9eb15322ab4207b5efd5f3dac36d75f (diff) | |
download | django-skaschool-9172b7f08a7dabde275253b47ad051600decbe7b.tar.bz2 |
* updated 'profile_update' template:
o account_profile_update.css account_profile_update.js
o added fields 'reason', 'transcript', 'supplement'
o supported upload files (optional, dynamical formset)
* updated urls.py of 'password_reset' view
-rw-r--r-- | account/static/css/account_profile_update.css | 13 | ||||
-rw-r--r-- | account/static/js/account_profile_update.js | 62 | ||||
-rw-r--r-- | account/templates/account/profile_update.html | 32 | ||||
-rw-r--r-- | account/urls.py | 4 |
4 files changed, 109 insertions, 2 deletions
diff --git a/account/static/css/account_profile_update.css b/account/static/css/account_profile_update.css new file mode 100644 index 0000000..665b2ab --- /dev/null +++ b/account/static/css/account_profile_update.css @@ -0,0 +1,13 @@ +/* + * account_profile_update.css + * for 'profile_update.html' template + */ + +.add-attachments .btn { + margin-top: -6px; +} + +.add-attachments + hr { + margin-top: 0; +} + diff --git a/account/static/js/account_profile_update.js b/account/static/js/account_profile_update.js new file mode 100644 index 0000000..8a91e28 --- /dev/null +++ b/account/static/js/account_profile_update.js @@ -0,0 +1,62 @@ +/* + * account_profile_update.js + * for 'profile_update.html' template + */ + +$(document).ready(function() { + // modify styles of supplment textarea within 'mainform' + $(".mainform textarea#id_supplement").attr('rows', 1); + $(".mainform textarea#id_supplement").focus(function() { + // show 5 rows when focused + $(this).attr('rows', 5); + }).blur(function() { + // show only 1 row when unfocus + $(this).attr('rows', 1); + }); + + // modify styles of file description textarea of subforms + $(".subform textarea").attr('rows', 1); + $(".subform textarea").focus(function() { + // show 3 rows when focused + $(this).attr('rows', 3); + }).blur(function() { + // show only 1 row when unfocus + $(this).attr('rows', 1); + }); + + // remove 'required' attribute of subform + $(".subform input").filter('[required]').removeAttr('required'); + + // add-subform button + // ref: http://stackoverflow.com/questions/501719/dynamically-adding-a-form-to-a-django-formset-with-ajax + function cloneMore(selector, type) { + var newElement = $(selector).clone(true); + var total = $('#id_' + type + '-TOTAL_FORMS').val(); + newElement.find(':input').each(function() { + // update name and id attributes + var name = $(this).attr('name').replace('-'+(total-1)+'-', '-'+total+'-'); + var id = 'id_' + name; + $(this).attr({'name': name, 'id': id}).val('').removeAttr('checked'); + }); + newElement.find('label').each(function() { + // update for attributes if exists + if ($(this).attr('for')) { + var newFor = $(this).attr('for').replace('-'+(total-1)+'-', '-'+total+'-'); + $(this).attr('for', newFor); + } + }); + // remove 'has-success has-error' classes and help-block + newElement.children().removeClass('has-success has-error'); + newElement.find('.help-block').remove(); + // update management_form settings + total++; + $('#id_' + type + '-TOTAL_FORMS').val(total); + $(selector).after(newElement); + } + + // Register the click event handlers + $("#add-subform").click(function () { + cloneMore('div.subform:last', 'userfile_set'); + }); +}); + diff --git a/account/templates/account/profile_update.html b/account/templates/account/profile_update.html index 1802bb0..2023aa9 100644 --- a/account/templates/account/profile_update.html +++ b/account/templates/account/profile_update.html @@ -1,6 +1,7 @@ {% extends 'base.html' %} {% load staticfiles %} {% load url from future %} +{% load i18n %} {% load bootstrap3 %} {# login template #} @@ -9,16 +10,45 @@ 更新个人信息 | 2014 SKA Summer School {% endblock %} +{% block css_extra %} + <link href="{% static 'css/account_profile_update.css' %}" rel="stylesheet"> +{% endblock %} + {% block content %} <div class="container"> <h2>更新个人信息</h2> <br> - <form role="form" class="form-horizontal" method="post"> + <form role="form" class="form-horizontal" method="post" enctype="multipart/form-data"> {% csrf_token %} + <div class="mainform"> {% bootstrap_form form layout='horizontal' %} + </div> + <hr> + <div class="row add-attachments"> + <!--<p><strong>上传附件(可选)</strong> --> + <div class="col-md-2"> + <p class="text-right"><strong>上传附件(可选)</strong></p> + </div> + <div class="col-md-4"> + <p><a id="add-subform" class="btn btn-info" role="button" href="javascript:void(0)">{% trans 'Add another attachment' %}</a></p> + </div> + </div> + <hr> + {# bootstrap_formset formset layout='horizontal' #} + {{ formset.management_form }} + {% for form in formset.forms %} + <div class="subform"> + {% bootstrap_form form layout='horizontal' %} + <hr> + </div> + {% endfor %} {% buttons submit='提交' reset='重置' layout='horizontal' %}{% endbuttons %} </form> </div> {% endblock %} +{% block js_extra %} + <script src="{% static 'js/account_profile_update.js' %}" type="text/javascript"></script> +{% endblock %} + {# vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=htmldjango.html: #} diff --git a/account/urls.py b/account/urls.py index ea6977b..8b68234 100644 --- a/account/urls.py +++ b/account/urls.py @@ -64,7 +64,9 @@ urlpatterns += patterns('django.contrib.auth.views', name='password_change_done'), ## reset password url(r'^password/reset/$', 'password_reset', - {'template_name': 'account/password_reset_form.html'}, + {'template_name': 'account/password_reset_form.html', + 'subject_template_name': 'account/password_reset_subject.txt', + 'email_template_name': 'account/password_reset_email.html',}, name='password_reset'), # reset password done url(r'^password/reset/done/$', 'password_reset_done', |