diff --git a/youmap/templates/auth/user_detail.html b/youmap/templates/auth/user_detail.html new file mode 100644 index 00000000..e3d1902c --- /dev/null +++ b/youmap/templates/auth/user_detail.html @@ -0,0 +1,33 @@ +{% extends "youmap/home.html" %} + +{% block content %} +
+
+ + + + {% include 'youmap/navigation.html' %} + + +
+
+ +
+
+

Browse {{ current_user }}'s maps

+
+
+
+
+
+ {% if maps %} + {% include "chickpea/map_list.html" %} + {% else %} +
+ {{ current_user }} has not map yet. +
+ {% endif %} +
+
+
+{% endblock content %} diff --git a/youmap/templates/chickpea/map_list.html b/youmap/templates/chickpea/map_list.html index 433f6291..a1d6aeca 100644 --- a/youmap/templates/chickpea/map_list.html +++ b/youmap/templates/chickpea/map_list.html @@ -5,7 +5,7 @@ {% for map_inst in maps %}
{% map_fragment map_inst %} -
{{ map_inst.name }} — {{ map_inst.description }} See this map!
+
{{ map_inst.name }} — «{{ map_inst.description }}» Cured by {{ map_inst.owner }}See this map!
{% endfor %} diff --git a/youmap/templates/youmap/home.html b/youmap/templates/youmap/home.html index ec44602a..389c4fc5 100644 --- a/youmap/templates/youmap/home.html +++ b/youmap/templates/youmap/home.html @@ -13,32 +13,7 @@ - - + {% include 'youmap/navigation.html' %} @@ -56,8 +31,8 @@
-

YouMap alpha


-
YouMap let you create maps with OpenStreetMap layers in a minute and embed them in your site.
This is a demo instance, you can host your own, it's open source! +

u{Map} alpha


+
u{Map} let you create maps with OpenStreetMap layers in a minute and embed them in your site.
This is a demo instance, you can host your own, it's open source!
diff --git a/youmap/templates/youmap/navigation.html b/youmap/templates/youmap/navigation.html new file mode 100644 index 00000000..6a713a64 --- /dev/null +++ b/youmap/templates/youmap/navigation.html @@ -0,0 +1,29 @@ + diff --git a/youmap/urls.py b/youmap/urls.py index 353a8006..95a4ef94 100644 --- a/youmap/urls.py +++ b/youmap/urls.py @@ -14,6 +14,7 @@ urlpatterns = patterns('', (r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/', include(admin.site.urls)), url(r'^$', views.home, name="home"), + url(r'^user/(?P[-_\w]+)/$', views.user_maps, name='user_maps'), (r'', include('chickpea.urls')), ) diff --git a/youmap/views.py b/youmap/views.py index 5345efd3..eed4f8cf 100644 --- a/youmap/views.py +++ b/youmap/views.py @@ -1,4 +1,6 @@ from django.views.generic import TemplateView +from django.contrib.auth.models import User +from django.views.generic import DetailView from chickpea.models import Map @@ -23,3 +25,29 @@ class Home(TemplateView): return [self.template_name] home = Home.as_view() + + +class UserMaps(DetailView): + model = User + slug_url_kwarg = 'username' + slug_field = 'username' + list_template_name = "chickpea/map_list.html" + context_object_name = "current_user" + + def get_context_data(self, **kwargs): + maps = Map.objects.filter(owner=self.object).order_by('-modified_at')[:30] + kwargs.update({ + "maps": maps + }) + return super(UserMaps, self).get_context_data(**kwargs) + + def get_template_names(self): + """ + Dispatch template according to the kind of request: ajax or normal. + """ + if self.request.is_ajax(): + return [self.list_template_name] + else: + return super(UserMaps, self).get_template_names() + +user_maps = UserMaps.as_view()