Commits

Anonymous committed bb60a15

Added user list and user detail pages.

  • Participants
  • Parent commits 0bb4c9d

Comments (0)

Files changed (5)

 RewriteRule ^(u/\w+/\w(\w|-|\.)+\w/edit/?)$ dispatch.fcgi/$1 [L]
 RewriteRule ^(u/\w+/\w(\w|-|\.)+\w/delete/?)$ dispatch.fcgi/$1 [L]
 
-RewriteRule ^(u/.+)$ hgfcgi/dispatch.fcgi/$1 [L]
+RewriteRule ^(u/\w+/\w(\w|-|\.)+\w/.+)$ hgfcgi/dispatch.fcgi/$1 [L]
 
 RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

templates/user_detail.html

+{% extends "base.html" %}
+
+{% block title %}{{ view_user.get_full_name }} ({{view_user.username}}){% endblock %}
+
+{% block content %}
+
+{% comment %} TODO this template has a lot of overlap with the profile.html template.  Perhaps some of it should be moved to inclusion tags?{% endcomment %}
+
+<div id="display-profile" class="span-8 box">
+<dl>
+    <dt>Username:</dt>
+        <dd>{{view_user.username}}</dd>
+    <dt>"Real" name:</dt>
+        <dd>{% if view_user.get_full_name %}{{view_user.get_full_name}}{% else %}Humanoid#001634{{view_user.id}} {% ifequal user view_user %}(<a href="/accounts/profile/#change-profile">Name yourself</a>){% else %}(This user has not told us his/her/its name.){% endifequal %}{%endif%}</dd>
+</dl>
+{% ifequal user view_user %}
+        <a href="/accounts/profile/#change-profile">Edit your profile.</a>
+    {% endifequal %}
+</div>
+
+{% comment %} TODO add last change time? {% endcomment %}
+{% if view_user.repo_set.count %}
+<div class="span-14 clear">
+    <table>
+    {% for repo in view_user.repo_set.all %}
+        <tr><td><a href="{{repo.get_absolute_url}}">
+            {{repo.get_long_name}}
+        </a></td>
+        <td>{{repo.disk_usage|filesizeformat}}</td>
+        {% ifequal user view_user %}
+            <td><a href="{{repo.get_absolute_url}}edit/">edit</a> | <a href="{{repo.get_absolute_url}}delete/">delete</a></td></tr>
+        {% endifequal %}
+    {% endfor %}
+    </table>
+</div>
+{% else %}
+This user has not created any repositories.
+{% endif %}
+
+{% comment %} TODO add a create repository form here?{% endcomment %}
+
+{% endblock %}

templates/user_list.html

+{% extends "base.html"%}
+
+{% block title %}Index of all users{%endblock%}
+
+{% block content %}
+
+<div class="span-14">
+    <table>
+        <thead>
+            <tr><td>Username</td><td>Real name</td><td>Repository count</td></tr>
+        </thead>
+        <tbody>
+            {% for u in users %}
+                <tr>
+                    <td><a href="/u/{{u.username}}/">{{u.username}}</a></td>
+                    <td>{{u.get_full_name}}</td>
+                    <td>{{u.repo_set.count}}</td>
+                </tr>
+            {% endfor %}
+        </tbody>
+    </table>
+</div>
+{% endblock %}
     (r'^u/(?P<username>\w+)/(?P<reponame>\w(\w|-|\.)+\w)/delete/$',
             'freehg.repos.views.delete_repo'),
     (r'^repo_deleted/$', direct_to_template, {'template':'repos/deleted.html'}),
-    
+
+    (r'^u/$', 'freehg.views.user_list'),
+    (r'^u/(?P<username>\w+)/$', 'freehg.views.user_detail'),
 
     # Uncomment this for admin:
     (r'^admin/', include('django.contrib.admin.urls')),
+from django.contrib.auth.models import User
+from django.shortcuts import get_object_or_404, render_to_response
+from django.template import RequestContext
+from django.contrib.auth.decorators import login_required
+from django.http import HttpResponseRedirect
+from django import newforms as forms
+
+# Why the heck aren't I using generic views???
+def user_list(request):
+    return render_to_response('user_list.html',
+            dict(users=User.objects.all()),
+            context_instance=RequestContext(request))
+
+def user_detail(request, username):
+    return render_to_response('user_detail.html',
+            dict(view_user=get_object_or_404(User, username=username)),
+            context_instance=RequestContext(request))