better presentation and automatic save for renkan from facettes
authorcavaliet
Wed, 23 Jul 2014 12:59:35 +0200
changeset 302 106c33871db4
parent 301 3ec8fb1afed8
child 303 88d36ba3f6c9
better presentation and automatic save for renkan from facettes
src/hdalab/templates/profile_home.html
src/hdalab/urls.py
src/hdalab/views/profile.py
--- a/src/hdalab/templates/profile_home.html	Tue Jul 22 17:06:21 2014 +0200
+++ b/src/hdalab/templates/profile_home.html	Wed Jul 23 12:59:35 2014 +0200
@@ -27,9 +27,10 @@
 {% block profile_actif %}actif{% endblock %}
 
 {% block main_content %}
-    <h2>Votre profil</h2>
-    <p><a href="{% url 'renkan_new' %}" >Nouveau Renkan</a></p>
-    <p>Vos renkans : </p>
+    <h2>Mon profil</h2>
+    <p><a href="{% url 'renkan_new' %}" >Nouveau Renkan</a> - <a href="{% url 'auth_password_change' %}">Modification du mot de passe</a></p>
+    <p>&nbsp;</p>
+    <p>Mes renkans : </p>
     <table id="rk-table">
       <thead>
         <tr class="border_bottom"><th>Nom</th><th>Date de modification</th><th>Preview</th><th>Statut</th><th>Actions</th></tr>
@@ -53,5 +54,4 @@
       {% endfor %}
       </tbody>
     </table>
-    <p>Gestion du mot de passe : <a href="{% url 'auth_password_change' %}">modification</a></p>
 {% endblock %}
\ No newline at end of file
--- a/src/hdalab/urls.py	Tue Jul 22 17:06:21 2014 +0200
+++ b/src/hdalab/urls.py	Wed Jul 23 12:59:35 2014 +0200
@@ -32,7 +32,7 @@
     url(r'^notice/(?P<hda_id>[\w-]+)$', 'hdalab.views.pages.datasheet', name='notice'),
     
     url(r'^renkan/new/$',login_required(RenkanNew.as_view()), name='renkan_new'),
-    url(r'^renkan/edit/$', login_required(RenkanEdit.as_view()), name='renkan_edit'),
+    url(r'^renkan/edit/$', RenkanEdit.as_view(), name='renkan_edit'),
     url(r'^renkan/getput/$', HdalabRenkanGetPut.as_view(), name='renkan_get_put'),
     url(r'^renkan/view/$', TemplateView.as_view(template_name="renkan_view.html"), name='renkan_view'),
     url(r'^renkan/copy/(?P<rk_id>.*)$', login_required(HdalabRenkanCopy.as_view()), name='renkan_copy'),
--- a/src/hdalab/views/profile.py	Tue Jul 22 17:06:21 2014 +0200
+++ b/src/hdalab/views/profile.py	Wed Jul 23 12:59:35 2014 +0200
@@ -98,12 +98,21 @@
             rk = get_object_or_404(Renkan, rk_id=rk_id)
             return HttpResponse(rk.content, content_type="application/json")
         
-        # Otherwise we build the datas    
+        # Otherwise we build the datas
+        # Get tags and countries
+        labels = request.GET.get("label", "").split(",")
+        countries = request.GET.get("country", "").split(",")
+        # Tags arrive with french label, countries with dbpedia uri
+        label_list = [t for t in labels if t!=""]
+        country_list = [c for c in countries if c!=""]
+        all_tags = Tag.objects.filter( Q(label__in=label_list) | Q(dbpedia_uri__in=country_list) ).select_related("dbpedia_fields")
+        
+        
         now = datetime.now().strftime("%Y-%m-%d %H:%M")
         
         content = {
           "id": unicode(uuid.uuid1()),
-          "title": "Renkan généré " + now,
+          "title": "",
           "description": "(empty description)",
           "created": now,
           "updated": now,
@@ -113,13 +122,6 @@
           "users": [],
         }
         
-        # Get tags and countries
-        labels = request.GET.get("label", "").split(",")
-        countries = request.GET.get("country", "").split(",")
-        # Tags arrive with french label, countries with dbpedia uri
-        label_list = [t for t in labels if t!=""]
-        country_list = [c for c in countries if c!=""]
-        all_tags = Tag.objects.filter( Q(label__in=label_list) | Q(dbpedia_uri__in=country_list) ).select_related("dbpedia_fields")
         
         # Get datasheets from ajax filter search
         filter_output = filter_generic(request.GET.get('lang',request.LANGUAGE_CODE), None, ",".join(label_list), ",".join(country_list))
@@ -131,6 +133,8 @@
         # Prepare other tags
         related_tags = []
         all_labels = [t.label for t in all_tags]
+        title = "Recherche " + ", ".join(all_labels)
+        content["title"] = title
         related_tags_dict = {}
         for c in filter_output["contents"]:
             c["id"] = unicode(uuid.uuid1())
@@ -208,7 +212,21 @@
                     #"created_by": "de68xf75y6hs5rgjhgghxbm217xk"
                 })
         
-        return HttpResponse(json.dumps(content), content_type="application/json")
+        response = json.dumps(content)
+        
+        if request.user.is_authenticated():
+            rk = Renkan()
+            rk.rk_id = unicode(uuid.uuid1())
+            rk.title = title
+            rk.content = response
+            rk.owner = request.user
+            rk.save()
+            hr = HdalabRenkan()
+            hr.renkan = rk
+            hr.state = HdalabRenkan.EDITION
+            hr.save()
+        
+        return HttpResponse(response, content_type="application/json")