Commits

angri  committed 1e7c989

bsproj теперь зависит от транковой версии django-registration. зато теперь можно зарегистрироваться.

  • Participants
  • Parent commits 9320639

Comments (0)

Files changed (6)

File bsproj/settings.py

     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.messages',
-    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
 
+    'registration',
+
     'brainstill',
 )

File bsproj/templates/layout0.html

   </div>
 {% endblock header %}
 
+  <div id="nav-menu">
+    <div id="account">
+      {% if user.is_authenticated %}
+        <p class="authenticated">
+          {% blocktrans %}Logged in as <strong>{{ user }}</strong>{% endblocktrans %}
+          |
+          <a href="{% url auth_logout %}">Log out</a>
+        </p>
+      {% else %}
+        <p class="anonymous">
+          <a href="{% url auth_login %}">{% trans "Log in" %}</a>
+          |
+          <a href="{% url registration_register %}">{% trans "Register" %}</a>
+        </p>
+      {% endif %}
+    </div>
+  </div>
+
 <div id="content">{% block content %}{% endblock content %}</div>
 
 {% block footer %}

File bsproj/templates/registration/login.html

       <dt>&nbsp;</dt>
       <dd>
         <button class="submit" type="submit">{% trans "Log in" %}</button>
+        <a href="{% url registration_register %}">{% trans "Register" %}</a>
       </dd>
     </dl>
   </form>

File bsproj/templates/registration/registration_form.html

+{% extends "layout0.html" %}
+{% load i18n %}
+
+{% block content %}
+  <h1>{% trans "Register" %}</h1>
+  <form action="" method="post" class="register">
+    {% csrf_token %}
+    <dl>
+      {% for field in form %}
+      <dt>{{ field.label_tag }}:</dt>
+      <dd>
+        {{ field }}
+        {{ field.errors }}
+        {% if forloop.last %}
+          {{ form.non_field_errors }}
+        {% endif %}
+      </dd>
+      {% endfor %}
+      <dt>&nbsp;</dt>
+      <dd>
+        <button class="submit" type="submit">{% trans "Register" %}</button>
+      </dd>
+    </dl>
+  </form>
+  <div style="clear: both"></div>
+{% endblock %}
+

File bsproj/urls.py

 urlpatterns = patterns('',
     url(r'^admin/', include(admin.site.urls)),
 
-    url(r'^login/$', 'django.contrib.auth.views.login'),
-    url(r'^logout/$', 'django.contrib.auth.views.logout', dict(next_page='/')),
+    url(r'^accounts/register/$', 'registration.views.register',
+        dict(backend='registration.backends.simple.SimpleBackend',
+             success_url='/'),
+        name='registration_register'),
+    url(r'^accounts/login/$', 'django.contrib.auth.views.login',
+        name='auth_login'),
+    url(r'^accounts/logout/$', 'django.contrib.auth.views.logout',
+        dict(next_page='/'),
+        name='auth_logout'),
 
     url(r'', include('brainstill.urls')),
 

File media/style.css

   border-bottom: 1px dotted #8ae234;
 }
 
+strong { font-weight: bold; }
+
 
 div#header {
   background: url('header.png') no-repeat;
 }
 
 
-#content { margin: 40px 40px 0 40px; }
+#content { margin: 0 40px; }
 #content h1 {
   font-size: 19pt;
   line-height: 220%;
 }
 
 
-div#nav-menu { font-size: 90%; }
-div#nav-menu ul, div#nav-menu ul li {
+div#nav-menu { font-size: 75%; }
+div#nav-menu ul, div#nav-menu ul li, div#nav-menu div {
   display: inline;
   margin-right: 1.3ex;
 }
 div#nav-menu ul { margin-right: 3em; }
+div#nav-menu { margin: 1ex 40px 0 40px; }
+div#nav-menu #account {
+  text-align: right;
+  text-transform: lowercase;
+}
 
 
 p.info {
   margin: 1ex;
 }
 form dt {
-  width: 150px;
+  width: 200px;
   clear: both;
   text-align: right;
 }
-form dd { width: 450px; }
+form dd { width: 400px; }
 form dd .errorlist li {
   color: #ef2929;
   font-size: 75%;