Matthew Marshall avatar Matthew Marshall committed 53a3ae3

Added login and profile pages.

Comments (0)

Files changed (5)

templates/base.html

 border:2px solid #DDDDDD;
 margin:0px;
 padding-left:2em;}
+
+#login-info {float:right;}
+#header h1 {float:left;}
+
+div.align-form label {float:left;min-width:120px;}
+div.align-form input {}
+div.align-form p, div.align-form ul.errorlist {clear:both;}
+/* div.align-form p {padding-bottom:18px;} */
 </style>
 
 </head>
     <div id="header" class="span-24">
         <h1><a href="http://freehg.org">FreeHG.org</a></h1>
 
-        {% if user.is_authenticated %}
-            You are logged in as <span id=#username><a href="/u/{{user.username}}">{{user.username}}</a></span>. (<a href="/logout/">Logout</a>)
-        {% else %}
-            Not logged in.
-        {% endif %}
+        <div id="login-info">
+            {% if user.is_authenticated %}
+                You are logged in as <span id=#username><a href="/u/{{user.username}}">{{user.username}}</a></span>. (<a href="/accounts/logout/">Logout</a>)
+            {% else %}
+                (<a href="/accounts/login/">Login</a>)
+            {% endif %}
+        </div>
 
     </div>
 

templates/profile.html

+{% extends "base.html" %}
+
+{% block title %}Profile for {{request.user.username}}{% endblock %}
+
+{% block content %}
+
+<div id="display-profile" class="span-8 box">
+<dl>
+    <dt>Username:</dt>
+        <dd>{{user.username}}</dd>
+    <dt>"Real" name:</dt>
+        <dd>{% if user.get_full_name %}{{user.get_full_name}}{% else %}Humanoid#001634{{user.id}} (<a href="#change-profile">Name yourself</a>){%endif%}</dd>
+    <dt>Email address:</dt>
+        <dd>{% if user.email %}{{user.email}}{%else%}stranded@desert.island (<a href="#change-profile">Rescue yourself</a>){%endif%}</dd>
+</dl>
+</div>
+
+<div id="change-profile" class=" span-8 align-form">
+<form method="post" target=".">
+<fieldset>
+<legend>Update Profile</legend>
+{{form.as_p}}
+<input type="submit" value="Update Profile"/>
+</form>
+</div>
+
+
+{% if user.repo_set.count %}
+<div class="span-14 clear">
+    {% for repo in user.repo_set.all %}
+        <p><a href="{{repo.get_absolute_url}}">
+            {% if repo.long_name %}{{repo.long_name}}
+            {% else %}{{repo.name}}{% endif %}
+        </a></p>
+    {% endfor %}
+</div>
+{% endif %}
+
+
+<script type="text/javascript">
+$(document).ready(function(){
+    if ($('#change-profile .errorlist').length ||
+            String(window.location).search("#change-profile") != -1){
+        $('#display-profile').hide();
+    } else {
+        $('#change-profile').hide();
+    }
+    $('#display-profile').append(
+                '<a href="#change-profile">Update Profile<'+'/a>');
+    $('#change-profile').append(
+                '(<a href="#display-profile">Cancel<'+'/a>)');
+    $('[href=#change-profile]').click(function(){
+        $('#display-profile').hide();
+        $('#change-profile').show();
+    });
+    $('[href=#display-profile]').click(function(){
+        $('#display-profile').show();
+        $('#change-profile').hide();
+    });
+});
+</script>
+
+{% endblock %}

templates/registration/login.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block title %}Login{% endblock %}
+
+{% block content %}
+
+{% if error_message %}
+<p class="error">{{ error_message }}</p>
+{% endif %}
+<div id="span-24 clear last">
+<form action="{{ app_path }}" method="post" id="login-form">
+  <div class="form-row span-16">
+    {% if form.username.errors %}{{ form.username.html_error_list }}{% endif %}
+    <p><label for="id_username">{% trans 'Username:' %}</label> <br /><input type="text" name="username" id="id_username" /></p>
+  </div>
+  <div class="form-row span-16 clear">
+    {% if form.password.errors %}{{ form.password.html_error_list }}{% endif %}
+    <p><label for="id_password">{% trans 'Password:' %}</label><br /> <input type="password" name="password" id="id_password" /></p>
+    <input type="hidden" name="this_is_the_login_form" value="1" />
+    <input type="hidden" name="post_data" value="{{ post_data }}" />
+  </div>
+  <div class="submit-row clear">
+    <label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}" />
+  </div>
+</form>
+
+<script type="text/javascript">
+document.getElementById('id_username').focus()
+</script>
+</div>
+{% endblock %}

templates/registration/password_change_form.html

 <form action="" method="post">
 
 {% if form.old_password.errors %}{{ form.old_password.html_error_list }}{% endif %}
-<p class="aligned wide"><label for="id_old_password">{% trans 'Old password:' %}</label>{{ form.old_password }}</p>
+<p><label for="id_old_password">{% trans 'Old password:' %}</label><br />{{ form.old_password }}</p>
 {% if form.new_password1.errors %}{{ form.new_password1.html_error_list }}{% endif %}
-<p class="aligned wide"><label for="id_new_password1">{% trans 'New password:' %}</label>{{ form.new_password1 }}</p>
+<p><label for="id_new_password1">{% trans 'New password:' %}</label><br />{{ form.new_password1 }}</p>
 {% if form.new_password2.errors %}{{ form.new_password2.html_error_list }}{% endif %}
-<p class="aligned wide"><label for="id_new_password2">{% trans 'Confirm password:' %}</label>{{ form.new_password2 }}</p>
+<p><label for="id_new_password2">{% trans 'Confirm password:' %}</label><br />{{ form.new_password2 }}</p>
 
 <p><input type="submit" value="{% trans 'Change my password' %}" /></p>
 </form>
     # Example:
     #(r'^freehg/', include('freehg.foo.urls')),
     (r'^$', 'freehg.repos.views.frontpage'),
-    (r'^logout/$', 'django.contrib.auth.views.logout'),
-    (r'^change_password/$', 'django.contrib.auth.views.password_change'),
-    (r'^change_password/done/$',
+    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
+    (r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
+    (r'^accounts/profile/$', 'freehg.accountviews.profile'),
+    (r'^accounts/change_password/$',
+            'django.contrib.auth.views.password_change'),
+    (r'^accounts/change_password/done/$',
             'django.contrib.auth.views.password_change_done'),
 
     # Uncomment this for admin:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.