1. Jonathan Fine
  2. django-moodle

Commits

Jonathan Fine  committed 3677b9c

moodle_urlmap/views.py: Add view(), recognises URL /user/<username>/.

  • Participants
  • Parent commits a5c16a1
  • Branches default

Comments (0)

Files changed (3)

File moodle-patches/patch0.diff

View file
+diff -r 26dc336d322c -r 4392eb886196 admin/user.php
+--- a/admin/user.php	Sat Jul 31 20:34:04 2010 +0100
++++ b/admin/user.php	Sat Jul 31 21:21:06 2010 +0100
+@@ -277,7 +277,7 @@
+             }
+             $fullname = fullname($user, true);
+ 
+-            $table->data[] = array ("<a href=\"../user/view.php?id=$user->id&amp;course=$site->id\">$fullname</a>",
++            $table->data[] = array ("<a href=\"../user/$user->username/\">$fullname</a>",
+                                 "$user->email",
+                                 "$user->city",
+                                 "$user->country",

File test_moodle_urlmap/moodle_urlmap/views.py

View file
 import urllib2
 from django.http import HttpResponse
 import re
-from moodledb.models import MdlCourse
+from moodledb.models import MdlCourse, MdlUser
+
+# http://pypi.python.org/pypi/django-http-proxy/0.3
+# http://lethain.com/entry/2008/sep/30/suffer-less-by-using-django-dev-server-as-a-proxy/
 
 def fix_url(s):
     return re.compile('localhost/moodle').sub('localhost:8000', s)
     course = MdlCourse.objects.get(shortname=shortname)
     url = 'course/view.php?id=' + str(course.id)
     return urlmap(request, url)
+
+def user(request, username):
+
+    user = MdlUser.objects.get(username=username)
+
+    url = 'user/view.php?id=' + str(user.id)
+    return urlmap(request, url)

File test_moodle_urlmap/urls.py

View file
     # Uncomment the next line to enable the admin:
     # (r'^admin/(.*)', admin.site.root),
     
+    (r'user/([a-zA-Z0-9]+)/', 'moodle_urlmap.views.user'),
     (r'([a-zA-Z]+[0-9]+/)', 'moodle_urlmap.views.urlmap2'),
     (r'(.*)', 'moodle_urlmap.views.urlmap')