user settings
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 12 Mar 2012 15:51:48 +0000 (16:51 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 12 Mar 2012 15:52:03 +0000 (16:52 +0100)
18 files changed:
apps/ajaxable/templatetags/ajaxable_tags.py
wolnelektury/settings.py
wolnelektury/static/css/base.css
wolnelektury/static/css/header.css
wolnelektury/static/js/dialogs.js
wolnelektury/templates/account/email.html [new file with mode: 0644]
wolnelektury/templates/account/password_change.html [new file with mode: 0644]
wolnelektury/templates/account/password_reset.html [new file with mode: 0644]
wolnelektury/templates/account/password_reset_done.html [new file with mode: 0644]
wolnelektury/templates/account/password_reset_from_key.html [new file with mode: 0644]
wolnelektury/templates/account/password_reset_key_message.txt [new file with mode: 0644]
wolnelektury/templates/account/password_set.html [new file with mode: 0644]
wolnelektury/templates/emailconfirmation/confirm_email.html [new file with mode: 0644]
wolnelektury/templates/openid/login.html
wolnelektury/templates/superbase.html
wolnelektury/templates/user.html [new file with mode: 0644]
wolnelektury/urls.py
wolnelektury/views.py

index 2f9a8c4..2290478 100644 (file)
@@ -2,6 +2,12 @@ from django import template
 from ajaxable.utils import placeholdized
 register = template.Library()
 
 from ajaxable.utils import placeholdized
 register = template.Library()
 
+
 @register.filter
 def placeholdize(form):
     return placeholdized(form)
 @register.filter
 def placeholdize(form):
     return placeholdized(form)
+
+
+@register.filter
+def placeholdized_ul(form):
+    return placeholdized(form).as_ul()
index e4cb32b..599e7fb 100644 (file)
@@ -108,6 +108,7 @@ MIDDLEWARE_CLASSES = [
     'maintenancemode.middleware.MaintenanceModeMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.middleware.cache.FetchFromCacheMiddleware',
     'maintenancemode.middleware.MaintenanceModeMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.middleware.cache.FetchFromCacheMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
 ]
 
 ROOT_URLCONF = 'wolnelektury.urls'
 ]
 
 ROOT_URLCONF = 'wolnelektury.urls'
@@ -122,7 +123,7 @@ AUTHENTICATION_BACKENDS = [
     'allauth.account.auth_backends.AuthenticationBackend',
 ]
 EMAIL_CONFIRMATION_DAYS = 2
     'allauth.account.auth_backends.AuthenticationBackend',
 ]
 EMAIL_CONFIRMATION_DAYS = 2
-LOGIN_URL = '/uzytkownicy/zaloguj/'
+LOGIN_URL = '/uzytkownik/login/'
 
 LOGIN_REDIRECT_URL = '/'
 
 
 LOGIN_REDIRECT_URL = '/'
 
index 3160611..54675a5 100755 (executable)
@@ -143,6 +143,7 @@ h2 {
 }
 .hidden-box {
     position: absolute;
 }
 .hidden-box {
     position: absolute;
+    left: 0;
     display: none;
     border: 1px solid #ddd;
     padding: 1em 1em .5em 1em;
     display: none;
     border: 1px solid #ddd;
     padding: 1em 1em .5em 1em;
index 39d4160..320fa89 100755 (executable)
@@ -234,3 +234,14 @@ a.menu span {
     line-height: 1.636em;
     
 }
     line-height: 1.636em;
     
 }
+
+
+
+#user-menu {
+       left: 0;
+       top: 2em;
+       width: 15em;
+}
+#user-menu a {
+       color: #0D7E85;
+}
index 9b8750d..d44dab3 100755 (executable)
@@ -58,7 +58,7 @@
             $('body').append($window);
 
             $window.jqm({
             $('body').append($window);
 
             $window.jqm({
-                ajax: '/uzytkownicy/zaloguj-utworz/?next=' + escape(window.location),
+                ajax: '/uzytkownik/zaloguj-utworz/?next=' + escape(window.location),
                 ajaxText: '<p><img src="' + STATIC_URL + 'img/indicator.gif" alt="*"/> ' + gettext("Loading") + '</p>',
                 target: $('.target', $window)[0],
                 overlay: 60,
                 ajaxText: '<p><img src="' + STATIC_URL + 'img/indicator.gif" alt="*"/> ' + gettext("Loading") + '</p>',
                 target: $('.target', $window)[0],
                 overlay: 60,
diff --git a/wolnelektury/templates/account/email.html b/wolnelektury/templates/account/email.html
new file mode 100644 (file)
index 0000000..1f0710b
--- /dev/null
@@ -0,0 +1,65 @@
+{% extends "account/base.html" %}
+{% load i18n %}
+{% load ajaxable_tags %}
+
+{% block titleextra %}{% trans "Account" %}{% endblock %}
+
+{% block body %}
+    <h1>{% trans "E-mail Addresses" %}</h1>
+
+{% if user.emailaddress_set.all %}
+<p class="normal-text">{% trans 'The following e-mail addresses are associated to your account:' %}</p>
+    
+<form action="{% url account_email %}" class="cuteform" method="post">
+{% csrf_token %}
+  {% for emailaddress in user.emailaddress_set.all %}
+      <label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
+      <input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary %}checked="checked"{%endif %} value="{{emailaddress.email}}"/>
+
+{{ emailaddress.email }}
+    {% if emailaddress.verified %}
+    <span class="verified">{% trans "Verified" %}</span>
+    {% else %}
+    <span class="unverified">{% trans "Unverified" %}</span>
+    {% endif %}
+      {% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
+</label>
+{% endfor %}
+
+<div style="margin-top:1em;">
+      <button class="secondaryAction" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button>
+      <button class="secondaryAction" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button>
+      <button class="primaryAction" type="submit" name="action_remove" >{% trans 'Remove' %}</button>
+</div>
+</form>
+
+{% else %} 
+<p class="normal-text"><strong>{% trans 'Warning:'%}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}</p>
+{% endif %}
+
+
+    <h1>{% trans "Add E-mail Address" %}</h1>
+    
+    <form method="post" action="" class="cuteform hidelabels">
+    <ul>
+        {% csrf_token %}
+               {{ add_email_form|placeholdized_ul }}
+        <li><button name="action_add" type="submit">{% trans "Add E-mail" %}</button></li>
+    </ul>
+    </form>
+    
+{% endblock %}
+
+
+{% block extrabody %}
+<script type="text/javascript">
+$(function(){
+$("button[name='action_remove']").click(function(){
+if (confirm("{% trans 'Do you really want to remove the selected e-mail address?' %}")) {
+return true;
+}
+return false;
+});
+});
+</script>
+{% endblock %}
diff --git a/wolnelektury/templates/account/password_change.html b/wolnelektury/templates/account/password_change.html
new file mode 100644 (file)
index 0000000..6abc0a9
--- /dev/null
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load ajaxable_tags %}
+
+{% block titleextra %}{% trans "Change Password" %}{% endblock %}
+
+{% block body %}
+    <h1>{% trans "Change Password" %}</h1>
+    
+    <form method="POST" action="" class="cuteform hidelabels">
+        {% csrf_token %}
+       <ul>
+            {{ password_change_form|placeholdized_ul }}
+            <li><input type="submit" name="action" value="{% trans "Change Password" %}"/></li>
+        </ul>
+    </form>
+{% endblock %}
diff --git a/wolnelektury/templates/account/password_reset.html b/wolnelektury/templates/account/password_reset.html
new file mode 100644 (file)
index 0000000..9a8bc19
--- /dev/null
@@ -0,0 +1,20 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load ajaxable_tags %}
+{% load account_tags %}
+
+{% block titleextra %}{% trans "Password Reset" %}{% endblock %}
+
+{% block body %}
+
+    <h1>{% trans "Password Reset" %}</h1>
+    <p class="normal-text">{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}</p>
+    
+    <form method="POST" action="" class="cuteform hidelabels">
+        {% csrf_token %}
+       <ul>
+               {{ password_reset_form|placeholdized_ul }}
+            <li><input type="submit" value="{% trans "Reset My Password" %}" /></li>
+         </ul>
+    </form>
+{% endblock %}
diff --git a/wolnelektury/templates/account/password_reset_done.html b/wolnelektury/templates/account/password_reset_done.html
new file mode 100644 (file)
index 0000000..9447109
--- /dev/null
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block titleextra %}{% trans "Password Reset" %}{% endblock %}
+
+{% block body %}
+    <h1>{% trans "Password Reset" %}</h1>
+    <p class="normal-text">{% trans "We have sent you an e-mail. You should receive it within a few minutes." %}</p>
+{% endblock %}
diff --git a/wolnelektury/templates/account/password_reset_from_key.html b/wolnelektury/templates/account/password_reset_from_key.html
new file mode 100644 (file)
index 0000000..5cdd68e
--- /dev/null
@@ -0,0 +1,26 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load ajaxable_tags %}
+
+{% block titleextra %}{% trans "Change Password" %}{% endblock %}
+
+{% block body %}
+    <h1>{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}</h1>
+    
+    {% if token_fail %}
+        {% url account_reset_password as passwd_reset_url %}
+        <p class="normal-text">{% blocktrans %}The password reset link was invalid, possibly because it has already been used.  Please request a <a href="{{ passwd_reset_url }}">new password reset</a>.{% endblocktrans %}</p>
+    {% else %}
+        {% if form %}
+            <form method="POST" action="" class="cuteform hidelabels">
+                {% csrf_token %}
+                <ul>
+                               {{ form|placeholdized_ul }}
+                               <li><input type="submit" name="action" value="{% trans "change password" %}"/></li>
+                </ul>
+            </form>
+        {% else %}
+            <p class="normal-text">{% trans 'Your password is now changed.' %}</p>
+        {% endif %}
+    {% endif %}
+{% endblock %}
diff --git a/wolnelektury/templates/account/password_reset_key_message.txt b/wolnelektury/templates/account/password_reset_key_message.txt
new file mode 100644 (file)
index 0000000..23db17a
--- /dev/null
@@ -0,0 +1,9 @@
+{% load i18n %}{% blocktrans with site.domain as site_domain and user.username as username %}You're receiving this e-mail because you or someone else has requested a password for your user account at {{site_domain}}.
+It can be safely ignored if you did not request a password reset. Click the link below to reset your password.
+
+{{password_reset_url}}
+
+In case you forgot, your username is {{username}}.
+
+Thanks for using our site!
+{% endblocktrans %}
\ No newline at end of file
diff --git a/wolnelektury/templates/account/password_set.html b/wolnelektury/templates/account/password_set.html
new file mode 100644 (file)
index 0000000..d061a46
--- /dev/null
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load ajaxable_tags %}
+
+{% block head_title %}{% trans "Set Password" %}{% endblock %}
+
+{% block body %}
+    <h1>{% trans "Set Password" %}</h1>
+    
+    <form method="POST" action="" class="cuteform hidelabels">
+        {% csrf_token %}
+       <ul>
+            {{ password_set_form|placeholdized_ul }}
+            <li><input type="submit" name="action" value="{% trans "Set Password" %}"/></li>
+        </ul>
+    </form>
+{% endblock %}
\ No newline at end of file
diff --git a/wolnelektury/templates/emailconfirmation/confirm_email.html b/wolnelektury/templates/emailconfirmation/confirm_email.html
new file mode 100644 (file)
index 0000000..0b74c11
--- /dev/null
@@ -0,0 +1,13 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block titleextra %}{% trans "E-mail Address Confirmation" %}{% endblock %}
+
+{% block body %}
+    <h1>{% trans "E-mail Address Confirmation" %}</h1>
+    {% if email_address %}
+        <p class="normal-text">{% blocktrans with email_address.email as email and email_address.user as user %}You have confirmed that <a href="mailto:{{email}}">{{ email }}</a> is an e-mail address for user '{{ user }}'.{% endblocktrans %}</p>
+    {% else %}
+        <p class="normal-text">{% trans "Invalid confirmation key." %}</p>
+    {% endif %}
+{% endblock %}
\ No newline at end of file
index afe7fe8..4741397 100644 (file)
@@ -14,9 +14,7 @@
 <form class="cuteform hidelabels" method="post" action="{% url openid_login %}">
 <ul>
        {% csrf_token %}
 <form class="cuteform hidelabels" method="post" action="{% url openid_login %}">
 <ul>
        {% csrf_token %}
-       {% with form|placeholdize as f %}
-       {{ f.as_ul }}
-    {% endwith %}
+       {{ form|placeholdized_ul }}
     <li><input type="submit" value='{% trans "Login" %}' /></li>
 </ul>
 </form>
     <li><input type="submit" value='{% trans "Login" %}' /></li>
 </ul>
 </form>
index 5813a2b..fade57b 100644 (file)
 
             <p id="user-info" class="mono">
                 {% if user.is_authenticated %}
 
             <p id="user-info" class="mono">
                 {% if user.is_authenticated %}
-                    {% trans "Welcome" %}, <strong>{{ user.username }}</strong>
+                    {% trans "Welcome" %}, 
+                       <span class="hidden-box-wrapper">
+                               <a href="{% url user_settings %}" class="hidden-box-trigger">
+                                       <strong>{{ user.username }}</strong>
+                               </a>
+                               <span id="user-menu" class="hidden-box">
+                                       <a href="{% url account_set_password %}">{% trans "Password" %}</a><br/>
+                                       <a href="{% url account_email %}">{% trans "E-mail" %}</a><br/>
+                                       <a href="{% url socialaccount_connections %}">{% trans "Social accounts" %}</a><br/>
+                               </span>
+                       </span>
                     | <a href="{% url social_my_shelf %}" id="user-shelves-link">{% trans "My shelf" %}</a>
                     {% if user.is_staff %}
                     | <a href="/admin/">{% trans "Administration" %}</a>
                     | <a href="{% url social_my_shelf %}" id="user-shelves-link">{% trans "My shelf" %}</a>
                     {% if user.is_staff %}
                     | <a href="/admin/">{% trans "Administration" %}</a>
         var pageTracker = _gat._getTracker("UA-2576694-1");
         pageTracker._trackPageview();
         </script>-->
         var pageTracker = _gat._getTracker("UA-2576694-1");
         pageTracker._trackPageview();
         </script>-->
+
+               {% block extrabody %}
+               {% endblock %}
     </body>
 </html>
     </body>
 </html>
diff --git a/wolnelektury/templates/user.html b/wolnelektury/templates/user.html
new file mode 100644 (file)
index 0000000..1d15033
--- /dev/null
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+
+{% block titleextra %}{% trans "User" %}{% endblock %}
+
+{% block body %}
+
+<h1>{% trans "User" %}</h1>
+
+<div class='normal-text'>
+<p><a href="{% url account_set_password %}">{% trans "Password" %}</a></p>
+<p><a href="{% url account_email %}">{% trans "E-mail" %}</a></p>
+<p><a href="{% url socialaccount_connections %}">{% trans "Social accounts" %}</a></p>
+</div>
+
+{% endblock %}
index 3695990..3806b73 100644 (file)
@@ -16,10 +16,11 @@ urlpatterns = patterns('wolnelektury.views',
     url(r'^zegar/$', 'clock', name='clock'),
 
     # Authentication
     url(r'^zegar/$', 'clock', name='clock'),
 
     # Authentication
-    url(r'^uzytkownicy/zaloguj/$', views.LoginFormView(), name='login'),
-    url(r'^uzytkownicy/utworz/$', views.RegisterFormView(), name='register'),
-    url(r'^uzytkownicy/wyloguj/$', 'logout_then_redirect', name='logout'),
-    url(r'^uzytkownicy/zaloguj-utworz/$', views.LoginRegisterFormView(), name='login_register'),
+    url(r'^uzytkownik/$', 'user_settings', name='user_settings'),
+    url(r'^uzytkownik/login/$', views.LoginFormView(), name='login'),
+    url(r'^uzytkownik/signup/$', views.RegisterFormView(), name='register'),
+    url(r'^uzytkownik/logout/$', 'logout_then_redirect', name='logout'),
+    url(r'^uzytkownik/zaloguj-utworz/$', views.LoginRegisterFormView(), name='login_register'),
 )
 
 urlpatterns += patterns('',
 )
 
 urlpatterns += patterns('',
@@ -32,7 +33,7 @@ urlpatterns += patterns('',
     url(r'^raporty/', include('reporting.urls')),
     url(r'^info/', include('infopages.urls')),
     url(r'^ludzie/', include('social.urls')),
     url(r'^raporty/', include('reporting.urls')),
     url(r'^info/', include('infopages.urls')),
     url(r'^ludzie/', include('social.urls')),
-    url(r'^uzytkownicy/', include('allauth.urls')),
+    url(r'^uzytkownik/', include('allauth.urls')),
 
     # Admin panel
     url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),
 
     # Admin panel
     url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),
index bcead03..cb1d2af 100755 (executable)
@@ -2,6 +2,7 @@ from datetime import datetime
 import feedparser
 
 from django.contrib import auth
 import feedparser
 
 from django.contrib import auth
+from django.contrib.auth.decorators import login_required
 from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
 from django.core.cache import cache
 from django.http import HttpResponse, HttpResponseRedirect
 from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
 from django.core.cache import cache
 from django.http import HttpResponse, HttpResponseRedirect
@@ -108,3 +109,9 @@ def publish_plan(request):
 
     return render_to_response("publish_plan.html", {'plan': plan},
         context_instance=RequestContext(request))
 
     return render_to_response("publish_plan.html", {'plan': plan},
         context_instance=RequestContext(request))
+
+
+@login_required
+def user_settings(request):
+    return render_to_response("user.html",
+        context_instance=RequestContext(request))