correct and first add subject
authorcavaliet
Wed, 04 Sep 2013 16:41:42 +0200
changeset 35 544bc92e6fe7
parent 34 cfc090f440d0
child 36 08cffedf6e60
correct and first add subject
src/p4l/static/p4l/js/p4l.js
src/p4l/templates/p4l/p4l_home.html
src/p4l/templates/p4l/record_update_form.html
src/p4l/urls.py
src/p4l/views.py
--- a/src/p4l/static/p4l/js/p4l.js	Wed Sep 04 16:17:04 2013 +0200
+++ b/src/p4l/static/p4l/js/p4l.js	Wed Sep 04 16:41:42 2013 +0200
@@ -10,6 +10,12 @@
 app.controller("RecordCtrl", function($scope, Api, context){
     $scope.record = Api.record.get({recordId: context.record_id});
     $scope.uriLabels = context.uri_labels;
+    
+    $scope.addSubject = function() {
+    	$scope.record.subjects.push($scope.addSubjectText);
+    	$scope.addSubjectText = '';
+    };
+    
 });
 
 app.config(['$routeProvider', function($routeProvider) {
--- a/src/p4l/templates/p4l/p4l_home.html	Wed Sep 04 16:17:04 2013 +0200
+++ b/src/p4l/templates/p4l/p4l_home.html	Wed Sep 04 16:41:42 2013 +0200
@@ -48,7 +48,7 @@
           {% endfor %}</ul></td>
       <td>
         <a class="btn btn-default" href="{% url 'p4l_record_view' slug=record.identifier %}"><i class="glyphicon glyphicon-eye-open"></i></a>
-        <a class="btn btn-default" href="{% url 'p4l_record_edit' id=record.identifier %}"><i class="glyphicon glyphicon-pencil"></i></a>
+        <a class="btn btn-default" href="{% url 'p4l_record_edit' slug=record.identifier %}"><i class="glyphicon glyphicon-pencil"></i></a>
       </td>
     </tr>
   {% empty %}
--- a/src/p4l/templates/p4l/record_update_form.html	Wed Sep 04 16:17:04 2013 +0200
+++ b/src/p4l/templates/p4l/record_update_form.html	Wed Sep 04 16:41:42 2013 +0200
@@ -12,7 +12,7 @@
     angular.module("recordApp")
         .value('context', {
             record_id: "{{record.identifier}}",
-            uri_labels: JSON.parse('{{uri_labels | safe}}'),
+            uri_labels: {{uri_labels | safe}},
             urls: {
                 record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":")
             }
@@ -42,6 +42,14 @@
           <ul ng-repeat="subject in record.subjects">
               <li>{{uriLabels[subject]}} <small class="text-muted">({{subject}})</small></li>
           </ul>
+          <form class="form-inline" role="form" ng-submit="addSubject()">
+	        <div class="form-group">
+	          <input ng-model="addSubjectText" class="form-control" type="text" placeholder="Add a new subject" required="required"/>
+	        </div>
+	        <div class="form-group">
+	          <button type="submit" class="btn btn-primary">Add</button>
+	        </div>
+	      </form>
       </td>
     </tr>
   </tbody>
@@ -50,8 +58,9 @@
 {% endverbatim %}
 <div class="row">
     <div class="col-md-12 text-right">
-      <a href="?uri={{ record.uri }}&lang=fr" alt="FR" /><img src="{% static 'p4l/img/blank.gif' %}" class="flag flag-fr" alt="FR" /></a>&nbsp;
-      <a href="?uri={{ record.uri }}&lang=en" alt="EN" /><img src="{% static 'p4l/img/blank.gif' %}" class="flag flag-gb" alt="EN" /></a>&nbsp;
-      <a href="?uri={{ record.uri }}&lang=es" alt="ES" /><img src="{% static 'p4l/img/blank.gif' %}" class="flag flag-es" alt="ES" /></a>
+      <a href="?lang=fr" alt="FR"><img src="{% static 'p4l/img/blank.gif' %}" class="flag flag-fr" alt="FR" /></a>&nbsp;
+      <a href="?lang=en" alt="EN"><img src="{% static 'p4l/img/blank.gif' %}" class="flag flag-gb" alt="EN" /></a>&nbsp;
+      <a href="?lang=es" alt="ES"><img src="{% static 'p4l/img/blank.gif' %}" class="flag flag-es" alt="ES" /></a>
+    </div>
 </div>
 {% endblock %}
\ No newline at end of file
--- a/src/p4l/urls.py	Wed Sep 04 16:17:04 2013 +0200
+++ b/src/p4l/urls.py	Wed Sep 04 16:41:42 2013 +0200
@@ -9,7 +9,7 @@
     url(r'^$', RecordListView.as_view(), name='p4l_home'),
     url(r'^auth/', include(auth_urls)),
     url(r'^record/view/(?P<slug>\w+)$', RecordDetailView.as_view(), name='p4l_record_view'),
-    url(r'^record/edit/(?P<id>\w+)$', RecordEditView.as_view(), name='p4l_record_edit'),
+    url(r'^record/edit/(?P<slug>\w+)$', RecordEditView.as_view(), name='p4l_record_edit'),
     url(r'^api/', include('p4l.api.urls')),
 
     # Uncomment the admin/doc line below to enable admin documentation:
--- a/src/p4l/views.py	Wed Sep 04 16:17:04 2013 +0200
+++ b/src/p4l/views.py	Wed Sep 04 16:41:42 2013 +0200
@@ -113,7 +113,6 @@
     template_name = 'p4l/record_update_form.html'
     model = Record
     slug_field = "identifier"
-    slug_url_kwarg = "id"
 
     def get_context_data(self, **kwargs):
         context = DetailView.get_context_data(self, **kwargs)