angular for simple sparql and checkbox. Languages updated
authorcavaliet
Tue, 10 Sep 2013 17:51:25 +0200
changeset 62 8433e12362e0
parent 61 305f9fcd409b
child 63 09a086a49b71
child 65 80868ae3009c
angular for simple sparql and checkbox. Languages updated
src/p4l/locale/en/LC_MESSAGES/django.mo
src/p4l/locale/en/LC_MESSAGES/django.po
src/p4l/locale/es/LC_MESSAGES/django.mo
src/p4l/locale/es/LC_MESSAGES/django.po
src/p4l/locale/fr/LC_MESSAGES/django.mo
src/p4l/locale/fr/LC_MESSAGES/django.po
src/p4l/models/data.py
src/p4l/settings.py
src/p4l/static/p4l/js/p4l.js
src/p4l/static/p4l/templates/simpleSemanticUriForm.html
src/p4l/templates/p4l/record_update_form.html
src/p4l/templates/p4l/translations.html
src/p4l/views.py
Binary file src/p4l/locale/en/LC_MESSAGES/django.mo has changed
--- a/src/p4l/locale/en/LC_MESSAGES/django.po	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/locale/en/LC_MESSAGES/django.po	Tue Sep 10 17:51:25 2013 +0200
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-09-06 12:13-0500\n"
+"POT-Creation-Date: 2013-09-10 10:40-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -289,12 +289,51 @@
 msgstr "Add"
 
 #: templates/p4l/translations.html:4
+msgid "Save"
+msgstr "Save"
+
+#: templates/p4l/translations.html:5
+msgid "Update"
+msgstr ""
+
+#: templates/p4l/translations.html:6
 msgid "Add a new subject"
 msgstr "Add a new subject"
 
-#: templates/p4l/translations.html:5
-msgid "Save"
-msgstr "Save"
+#: templates/p4l/translations.html:7
+#, fuzzy
+msgid "Add a new theme"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:8
+#, fuzzy
+msgid "Add a new country"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:9
+#, fuzzy
+msgid "Add a new language"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:10
+#, fuzzy
+msgid "Add a new project"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:11
+#, fuzzy
+msgid "Add a new organization"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:12
+#, fuzzy
+msgid "Modify the language"
+msgstr "other languages"
+
+#: templates/p4l/translations.html:13
+#, fuzzy
+msgid "Modify the record type"
+msgstr "record type"
 
 #: templates/registration/login.html:8
 msgid "Sorry, that's not a valid username or password."
Binary file src/p4l/locale/es/LC_MESSAGES/django.mo has changed
--- a/src/p4l/locale/es/LC_MESSAGES/django.po	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/locale/es/LC_MESSAGES/django.po	Tue Sep 10 17:51:25 2013 +0200
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-09-06 12:13-0500\n"
+"POT-Creation-Date: 2013-09-10 10:40-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -290,12 +290,51 @@
 msgstr "Add"
 
 #: templates/p4l/translations.html:4
+msgid "Save"
+msgstr "Save"
+
+#: templates/p4l/translations.html:5
+msgid "Update"
+msgstr ""
+
+#: templates/p4l/translations.html:6
 msgid "Add a new subject"
 msgstr "Add a new subject"
 
-#: templates/p4l/translations.html:5
-msgid "Save"
-msgstr "Save"
+#: templates/p4l/translations.html:7
+#, fuzzy
+msgid "Add a new theme"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:8
+#, fuzzy
+msgid "Add a new country"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:9
+#, fuzzy
+msgid "Add a new language"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:10
+#, fuzzy
+msgid "Add a new project"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:11
+#, fuzzy
+msgid "Add a new organization"
+msgstr "Add a new subject"
+
+#: templates/p4l/translations.html:12
+#, fuzzy
+msgid "Modify the language"
+msgstr "other languages"
+
+#: templates/p4l/translations.html:13
+#, fuzzy
+msgid "Modify the record type"
+msgstr "record type"
 
 #: templates/registration/login.html:8
 msgid "Sorry, that's not a valid username or password."
Binary file src/p4l/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/p4l/locale/fr/LC_MESSAGES/django.po	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/locale/fr/LC_MESSAGES/django.po	Tue Sep 10 17:51:25 2013 +0200
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-09-06 12:13-0500\n"
+"POT-Creation-Date: 2013-09-10 10:40-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,7 +17,9 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-#: admin.py:10 forms.py:36 templates/p4l/p4l_record_view.html:51
+#: admin.py:10
+#: forms.py:36
+#: templates/p4l/p4l_record_view.html:51
 msgid "language"
 msgstr "langue"
 
@@ -37,20 +39,22 @@
 msgid "Search"
 msgstr "Chercher"
 
-#: semantictree/forms/widgets.py:43 semantictree/forms/widgets.py:80
+#: semantictree/forms/widgets.py:43
+#: semantictree/forms/widgets.py:80
 msgid ""
 "\"data-url\", \"data-query\", \"data-root-query\", \"data-childs-query\" and "
 "\"data-child-count-query\" must be set in CharField configuration"
-msgstr ""
-"\"data-url\", \"data-query\", \"data-root-query\", \"data-childs-query\" et "
+msgstr "\"data-url\", \"data-query\", \"data-root-query\", \"data-childs-query\" et "
 "\"data-child-count-query\" doivent être renseignés dans la configuration "
 "CharField"
 
-#: semantictree/forms/widgets.py:44 semantictree/forms/widgets.py:81
+#: semantictree/forms/widgets.py:44
+#: semantictree/forms/widgets.py:81
 msgid "Browse"
 msgstr "Parcourir"
 
-#: semantictree/forms/widgets.py:49 semantictree/forms/widgets.py:86
+#: semantictree/forms/widgets.py:49
+#: semantictree/forms/widgets.py:86
 msgid "or"
 msgstr "ou"
 
@@ -58,16 +62,19 @@
 msgid "logout"
 msgstr "deconnection"
 
-#: templates/p4l/p4l_base.html:37 templates/registration/login.html:4
+#: templates/p4l/p4l_base.html:37
+#: templates/registration/login.html:4
 #: templates/registration/login.html:27
 msgid "login"
 msgstr "connection"
 
-#: templates/p4l/p4l_home.html:6 templates/p4l/p4l_home.html.py:10
+#: templates/p4l/p4l_home.html:6
+#: templates/p4l/p4l_home.html.py:10
 msgid "Record List"
 msgstr "Liste notice"
 
-#: templates/p4l/p4l_home.html:6 templates/p4l/p4l_home.html.py:29
+#: templates/p4l/p4l_home.html:6
+#: templates/p4l/p4l_home.html.py:29
 #: templates/p4l/p4l_home.html:66
 msgid "Page"
 msgstr "Page"
@@ -76,19 +83,23 @@
 msgid "Title"
 msgstr "Titre"
 
-#: templates/p4l/p4l_home.html:26 templates/p4l/p4l_home.html.py:63
+#: templates/p4l/p4l_home.html:26
+#: templates/p4l/p4l_home.html.py:63
 msgid "Previous"
 msgstr "Préc."
 
-#: templates/p4l/p4l_home.html:29 templates/p4l/p4l_home.html.py:66
+#: templates/p4l/p4l_home.html:29
+#: templates/p4l/p4l_home.html.py:66
 msgid "on"
 msgstr "sur"
 
-#: templates/p4l/p4l_home.html:32 templates/p4l/p4l_home.html.py:69
+#: templates/p4l/p4l_home.html:32
+#: templates/p4l/p4l_home.html.py:69
 msgid "Next"
 msgstr "Suiv."
 
-#: templates/p4l/p4l_home.html:39 templates/p4l/p4l_record_view.html:59
+#: templates/p4l/p4l_home.html:39
+#: templates/p4l/p4l_record_view.html:59
 msgid "titles"
 msgstr "titres"
 
@@ -291,21 +302,56 @@
 msgstr "Ajouter"
 
 #: templates/p4l/translations.html:4
+msgid "Save"
+msgstr "Sauver"
+
+#: templates/p4l/translations.html:5
+msgid "Update"
+msgstr "Mettre à jour"
+
+#: templates/p4l/translations.html:6
 msgid "Add a new subject"
 msgstr "Ajouter un nouveau sujet"
 
-#: templates/p4l/translations.html:5
-msgid "Save"
-msgstr "Sauver"
+#: templates/p4l/translations.html:7
+msgid "Add a new theme"
+msgstr "Ajouter un nouveau thème"
+
+#: templates/p4l/translations.html:8
+msgid "Add a new country"
+msgstr "Ajouter un nouveau pays"
+
+#: templates/p4l/translations.html:9
+msgid "Add a new language"
+msgstr "Ajouter une nouvelle langue"
+
+#: templates/p4l/translations.html:10
+msgid "Add a new project"
+msgstr "Ajouter un nouveau projet"
+
+#: templates/p4l/translations.html:11
+msgid "Add a new organization"
+msgstr "Ajouter une nouvelle organisation"
+
+#: templates/p4l/translations.html:12
+msgid "Modify the language"
+msgstr "Modifier la langue"
+
+#: templates/p4l/translations.html:13
+msgid "Modify the record type"
+msgstr "Modifier le type de notice"
 
 #: templates/registration/login.html:8
 msgid "Sorry, that's not a valid username or password."
 msgstr "Désolé, utilisateur ou mot de passe invalide"
 
-#: templates/registration/login.html:14 templates/registration/login.html:16
+#: templates/registration/login.html:14
+#: templates/registration/login.html:16
 msgid "Username"
 msgstr "Utilisateur"
 
-#: templates/registration/login.html:20 templates/registration/login.html:22
+#: templates/registration/login.html:20
+#: templates/registration/login.html:22
 msgid "Password"
 msgstr "Mot de passe"
+
--- a/src/p4l/models/data.py	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/models/data.py	Tue Sep 10 17:51:25 2013 +0200
@@ -167,7 +167,7 @@
     #subjectMeetings = foreign key from 'p4l.SubjectMeeting' #iiep:subjectMeeting
     corporateAuthors = models.ManyToManyField('p4l.CorporateAuthor', related_name='recordsCorporateAuthor') #iiep:subjectCorporateBody # <Organizations>
     #urls foreign Key from Url #iiep:url
-    recordType = models.URLField(max_length=2048) #dct:type
+    recordType = models.URLField(max_length=2048) #dct:type                                                                # <DocumentType>
     
     isDocumentPart = models.BooleanField() #iiep:isDocumentPart
     isMultilingual = models.BooleanField() #iiep:isMultilingual
--- a/src/p4l/settings.py	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/settings.py	Tue Sep 10 17:51:25 2013 +0200
@@ -454,6 +454,41 @@
 }
 """
 }
+SPARQL_TYPE_QUERIES = {
+'filter' : """
+PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
+PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX owl:<http://www.w3.org/2002/07/owl#>
+PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
+SELECT DISTINCT ?uri ?label
+WHERE {
+    ?uri a skos:Concept.
+    ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> .
+    ?uri skos:prefLabel ?label.
+    FILTER (lang(?label) = %s).
+    ?uri skos:prefLabel ?lab.
+    FILTER regex (str(?lab), ?reg, 'i').
+    FILTER (lang (?lab) = %s).
+    BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
+    BIND (STRLEN(STR(?lab)) AS ?len)
+}
+ORDER BY ?place ?len ?lab
+""",
+'root' : """
+PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
+PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX owl:<http://www.w3.org/2002/07/owl#>
+PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
+SELECT DISTINCT ?uri ?label
+WHERE {
+    ?uri a skos:Concept ;
+    skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> ;    
+    skos:prefLabel ?label .
+    FILTER (lang(?label) = %s). 
+    FILTER NOT EXISTS { [skos:narrower ?uri] }
+}
+"""
+}
 
 
 REST_FRAMEWORK = {
--- a/src/p4l/static/p4l/js/p4l.js	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/static/p4l/js/p4l.js	Tue Sep 10 17:51:25 2013 +0200
@@ -167,6 +167,50 @@
     }
 });
 
+app.directive('simpleSemUri', function(RecordModel, context, $timeout){
+	  return {
+	      restrict: 'E',
+	      replace: true,
+	      transclude: true,
+	      scope: {
+	    	  listname:"@",
+	    	  val:"=",
+	    	  placeholder:"@",
+	      },
+	      templateUrl: function(tElement, tAttrs) {
+	          return context.urls.base_static+'p4l/templates/simpleSemanticUriForm.html';  
+	      },
+	      link: function($scope, $element, $attrs) {
+	    	  // Get queries attributes from $scope listname and context query dict
+	    	  attr_dict = context.query_dicts[$scope.listname];
+	    	  for (var k in attr_dict){
+				  if (attr_dict.hasOwnProperty(k)) {
+				      $scope[k] = attr_dict[k];
+				  }
+			  }
+	    	  // initalize autocomplete and browse thesaurus events
+	    	  // We have to timeout because init_browse needs the real ids and not {{ $id }}
+	    	  // NB : scope.apply generates bug
+	    	  $timeout(function(){
+	    		  init_autocomplete();
+	    		  init_browse();
+	          }, 0);
+	      },
+	      controller: function($scope, $element, $attrs, $transclude, RecordModel){
+		    $scope.record = RecordModel.record;
+		    $scope.uriLabels = RecordModel.uriLabels;
+		    $scope.addUriText = '';
+		    
+		    $scope.updateVal = function() {
+		        $scope.val = $scope.addUriText;
+		    };
+		    
+		    $scope.updateUriLabelDict = function(k,v) {
+		        $scope.uriLabels[k] = v;
+		    };
+	      }
+	    }
+	});
 
 app.controller("RecordCtrl", function($scope, RecordModel, context){
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/p4l/static/p4l/templates/simpleSemanticUriForm.html	Tue Sep 10 17:51:25 2013 +0200
@@ -0,0 +1,18 @@
+<div>
+    <p>{{uriLabels[val]}} <small class="text-muted">({{val}})</small></p>
+	<form class="form-inline" role="form">
+	    <div class="form-group col-md-8">
+	        <input id="id_{{ $id }}" ng-model="addUriText" class="semantic-tree form-control col-md-10" type="text" placeholder="{{ placeholder }}"
+	               data-url="{{ dataurl }}" data-query="{{ dataquery }}" data-root-query="{{ datarootquery }}"
+	               data-childs-query="{{ datachildsquery }}" data-child-count-query="{{ datachildcountquery }}" />
+	        {{ 'or' | translate}}
+	        <span id="dialog-link-container-{{ $id }}" class="dialog-link-container ui-state-default ui-corner-all">
+	            <a href="#" id="dialog-link-{{ $id }}" class="btn dialog-link" title="Browse">{{'Browse' | translate}}</a>
+	        </span>
+	        <span id="dialog-{{ $id }}" class="dialog" title="Select term"><span id="term-tree-{{ $id }}"></span></span>
+	    </div>
+	    <div class="form-group">
+	        <button type="submit" class="btn btn-primary" ng-click="updateVal()">{{'Update' | translate}}</button>
+	    </div>
+	</form>
+</div>
\ No newline at end of file
--- a/src/p4l/templates/p4l/record_update_form.html	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/templates/p4l/record_update_form.html	Tue Sep 10 17:51:25 2013 +0200
@@ -85,7 +85,7 @@
     </tr>
     <tr>
       <td>{{ 'language' | translate }}</td>
-      <td><small>#todo WITH SPARQL</small></td>
+      <td><simple-sem-uri val="record.language" listname="languages" placeholder="{{'Modify the language' | translate}}"></simple-sem-uri></td>
 </td>
     </tr>
     <tr>
@@ -177,15 +177,15 @@
     </tr>
     <tr>
       <td>{{ 'record type' | translate }}</td>
-      <td><small>#todo WITH SPARQL</small></td>
+      <td><simple-sem-uri val="record.recordType" listname="types" placeholder="{{'Modify the record type' | translate}}"></simple-sem-uri></td>
     </tr>
     <tr>
       <td>{{ 'is document part' | translate }}</td>
-      <td><small>#todo checkbox</small></td>
+      <td><input type="checkbox" ng-model="record.isDocumentPart" /></td>
     </tr>
     <tr>
       <td>{{ 'is multilingual' | translate }}</td>
-      <td><small>#todo checkbox</small></td>
+      <td><input type="checkbox" ng-model="record.isMultilingual" /></td>
     </tr>
   </tbody>
 </table>
--- a/src/p4l/templates/p4l/translations.html	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/templates/p4l/translations.html	Tue Sep 10 17:51:25 2013 +0200
@@ -2,9 +2,12 @@
 
 {% trans 'Add' %}
 {% trans 'Save' %}
+{% trans 'Update' %}
 {% trans 'Add a new subject' %}
 {% trans 'Add a new theme' %}
 {% trans 'Add a new country' %}
 {% trans 'Add a new language' %}
 {% trans 'Add a new project' %}
-{% trans 'Add a new organisation' %}
\ No newline at end of file
+{% trans 'Add a new organization' %}
+{% trans 'Modify the language' %}
+{% trans 'Modify the record type' %}
\ No newline at end of file
--- a/src/p4l/views.py	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/views.py	Tue Sep 10 17:51:25 2013 +0200
@@ -169,6 +169,13 @@
                 'datarootquery': settings.SPARQL_ORGANIZATION_QUERIES["root"],
                 'datachildsquery': "",
                 'datachildcountquery': ""
+            },
+            'types' : {
+                'dataurl': settings.SPARQL_QUERY_ENDPOINT,
+                'dataquery': settings.SPARQL_TYPE_QUERIES["filter"] % (lang, lang),
+                'datarootquery': settings.SPARQL_TYPE_QUERIES["root"] % lang,
+                'datachildsquery': "",
+                'datachildcountquery': ""
             }
         }
         context['query_dicts'] = json.dumps(query_dicts)