Commit 58bce9e0c6d43987b89500ffcf7f059bab2f9b42
Committed by
Sergio Oliveira
1 parent
ed436f44
Exists in
master
and in
39 other branches
Update register and login buttons
Signed-off-by: Alexandre Barbosa <alexandreab@live.com> Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com> Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
Showing
4 changed files
with
41 additions
and
25 deletions
Show diff stats
colab/accounts/templates/accounts/user_create_form.html
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <label>{% trans "Required fields" %}</label> |
| 18 | 18 | </p> |
| 19 | 19 | |
| 20 | -<form action="." method="post" role="form" class="form-horizontal signup"> | |
| 20 | +<form action="{% url "signup" %}" method="post" role="form" class="form-horizontal signup"> | |
| 21 | 21 | {% csrf_token %} |
| 22 | 22 | |
| 23 | 23 | <div class="row"> | ... | ... |
colab/accounts/urls.py
| ... | ... | @@ -9,32 +9,15 @@ from django.contrib.auth import views as auth_views |
| 9 | 9 | |
| 10 | 10 | from colab.settings import BROWSERID_ENABLED |
| 11 | 11 | |
| 12 | -urlpatterns = patterns('', | |
| 13 | - url(r'^register/$', 'colab.accounts.views.signup', name='signup'), | |
| 14 | - | |
| 15 | -#FIXME Configure for XMPP | |
| 16 | -# url(r'^change-password/$', | |
| 17 | -# ChangeXMPPPasswordView.as_view(), name='change_password'), | |
| 18 | - | |
| 19 | - url(r'^(?P<username>[\w@+.-]+)/?$', | |
| 20 | - UserProfileDetailView.as_view(), name='user_profile'), | |
| 21 | - | |
| 22 | - url(r'^(?P<username>[\w@+.-]+)/edit/?$', | |
| 23 | - UserProfileUpdateView.as_view(), name='user_profile_update'), | |
| 24 | - | |
| 25 | - url(r'^(?P<username>[\w@+.-]+)/subscriptions/?$', | |
| 26 | - ManageUserSubscriptionsView.as_view(), name='user_list_subscriptions'), | |
| 27 | -) | |
| 28 | 12 | |
| 29 | 13 | if not BROWSERID_ENABLED: |
| 30 | - urlpatterns += patterns('', | |
| 14 | + urlpatterns = patterns('', | |
| 31 | 15 | url(r'^login/?$', 'django.contrib.auth.views.login', name='login'), |
| 32 | 16 | |
| 33 | 17 | url(r'^logout/?$', 'django.contrib.auth.views.logout', name='logout'), |
| 34 | 18 | |
| 35 | 19 | url(r'^password-reset-done/?$', 'colab.accounts.views.password_reset_done_custom', |
| 36 | 20 | name="password_reset_done"), |
| 37 | - | |
| 38 | 21 | url(r'^password-reset-complete/$', 'colab.accounts.views.password_reset_complete_custom', |
| 39 | 22 | name="password_reset_complete"), |
| 40 | 23 | |
| ... | ... | @@ -55,6 +38,23 @@ if not BROWSERID_ENABLED: |
| 55 | 38 | 'colab.accounts.views.password_changed', name='password_change_done'), |
| 56 | 39 | ) |
| 57 | 40 | else: |
| 58 | - urlpatterns += patterns('', | |
| 59 | - url(r'^login/?$', LoginView.as_view(), name='login'), | |
| 41 | + urlpatterns = patterns('', | |
| 42 | + url(r'^login/?$', LoginView.as_view(), name='colab.login'), | |
| 60 | 43 | ) |
| 44 | + | |
| 45 | +urlpatterns += patterns('', | |
| 46 | + url(r'^register/?$', 'colab.accounts.views.signup', name='signup'), | |
| 47 | + | |
| 48 | +#FIXME Configure for XMPP | |
| 49 | +# url(r'^change-password/$', | |
| 50 | +# ChangeXMPPPasswordView.as_view(), name='change_password'), | |
| 51 | + | |
| 52 | + url(r'^(?P<username>[\w@+.-]+)/?$', | |
| 53 | + UserProfileDetailView.as_view(), name='user_profile'), | |
| 54 | + | |
| 55 | + url(r'^(?P<username>[\w@+.-]+)/edit/?$', | |
| 56 | + UserProfileUpdateView.as_view(), name='user_profile_update'), | |
| 57 | + | |
| 58 | + url(r'^(?P<username>[\w@+.-]+)/subscriptions/?$', | |
| 59 | + ManageUserSubscriptionsView.as_view(), name='user_list_subscriptions'), | |
| 60 | +) | ... | ... |
colab/accounts/views.py
| ... | ... | @@ -146,7 +146,10 @@ def signup(request): |
| 146 | 146 | # If the user is authenticated in Persona, but not in the Colab then he |
| 147 | 147 | # will be redirected to the register form. |
| 148 | 148 | if request.method == 'GET': |
| 149 | - user_form = UserCreationForm() | |
| 149 | + if BROWSERID_ENABLED: | |
| 150 | + user_form = UserCreationForm() | |
| 151 | + else: | |
| 152 | + user_form = UserCreationFormNoBrowserId() | |
| 150 | 153 | lists_form = ListsForm() |
| 151 | 154 | |
| 152 | 155 | return render(request, 'accounts/user_create_form.html', |
| ... | ... | @@ -187,6 +190,7 @@ def signup(request): |
| 187 | 190 | |
| 188 | 191 | messages.success(request, _('Your profile has been created!')) |
| 189 | 192 | |
| 193 | + | |
| 190 | 194 | return redirect('user_profile', username=user.username) |
| 191 | 195 | |
| 192 | 196 | ... | ... |
colab/templates/base.html
| ... | ... | @@ -55,7 +55,9 @@ |
| 55 | 55 | |
| 56 | 56 | <!-- data-no-turbolink will disable Rails TurboLinks for all pages under Colab --> |
| 57 | 57 | <body class="container" data-no-turbolink> |
| 58 | - {% browserid_info %} | |
| 58 | + {% if BROWSERID_ENABLED %} | |
| 59 | + {% browserid_info %} | |
| 60 | + {% endif %} | |
| 59 | 61 | |
| 60 | 62 | {% block ribbon %} |
| 61 | 63 | {% if ribbon %} |
| ... | ... | @@ -110,11 +112,21 @@ |
| 110 | 112 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Acesso <b class="caret"></b></a> |
| 111 | 113 | <ul class="dropdown-menu"> |
| 112 | 114 | {% trans 'Login' as login_text %} |
| 113 | - <li>{% browserid_login text=login_text %}</li> | |
| 115 | + {% if BROWSERID_ENABLED %} | |
| 116 | + <li>{% browserid_login text=login_text %}</li> | |
| 117 | + {% else %} | |
| 118 | + <li><a href="{% url 'signup' %}">{% trans "Register" %}</a></li> | |
| 119 | + <li><a href="{% url 'login' %}">{% trans "Login" %}</a></li> | |
| 120 | + {% endif %} | |
| 114 | 121 | </ul> |
| 115 | 122 | </li> |
| 116 | 123 | {% trans 'Login' as login_text %} |
| 117 | - <li class="visible-xs hidden-sm hidden-md">{% browserid_login text=login_text %}</li> | |
| 124 | + {% if BROWSERID_ENABLED %} | |
| 125 | + <li class="visible-xs hidden-sm hidden-md">{% browserid_login text=login_text %}</li> | |
| 126 | + {% else %} | |
| 127 | + <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'signup' %}">{% trans "Register" %}</a></li> | |
| 128 | + <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'login' %}">{% trans "Login" %}</a></li> | |
| 129 | + {% endif %} | |
| 118 | 130 | {% else %} |
| 119 | 131 | <li id="user-menu" class="dropdown"> |
| 120 | 132 | <a href="#" class="dropdown-toggle user" data-toggle="dropdown">{% gravatar user.email 40 %} <b class="caret"></b> </a> | ... | ... |