# HG changeset patch # User wakimd # Date 1287139003 -7200 # Node ID 9927a619d2b59d8621ba2554fba05dfc3d84bbe7 # Parent 2f978b081c4ca8d5535e85d6ad275029ceb7ed80# Parent 7f2c2d9adf58ea9652c24180f67b640d13ca8709 Merge and corrections due to merge diff -r 2f978b081c4c -r 9927a619d2b5 .hgtags --- a/.hgtags Thu Oct 14 12:17:31 2010 +0200 +++ b/.hgtags Fri Oct 15 12:36:43 2010 +0200 @@ -22,3 +22,4 @@ fa03084f5fea9327a34f5cb6e2823d1bd7a8778c V00.18 d2c2d9e8523ed24d830501b8b8fc3fc4cdaf4e96 V00.19 de326ccbad7d068054879417a83ef95f9e904dde V00.20 +9bee2e1e34b9d48096acf5bd849cfacc0179ade5 V00.21 diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/__init__.py --- a/web/franceculture/__init__.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/franceculture/__init__.py Fri Oct 15 12:36:43 2010 +0200 @@ -1,4 +1,4 @@ -VERSION = (0, 20, 0, "final", 0) +VERSION = (0, 21, 0, "final", 0) VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2]))) diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/locale/fr/LC_MESSAGES/django.mo Binary file web/franceculture/locale/fr/LC_MESSAGES/django.mo has changed diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/locale/fr/LC_MESSAGES/django.po --- a/web/franceculture/locale/fr/LC_MESSAGES/django.po Thu Oct 14 12:17:31 2010 +0200 +++ b/web/franceculture/locale/fr/LC_MESSAGES/django.po Fri Oct 15 12:36:43 2010 +0200 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-09-20 22:09-0500\n" +"POT-Creation-Date: 2010-10-12 03:19+0200\n" "PO-Revision-Date: 2010-02-17 02:57+0100\n" "Last-Translator: Yves-Marie Haussonne \n" "Language-Team: LANGUAGE \n" @@ -20,9 +20,13 @@ msgid "French" msgstr "Français" +#: views.py:88 +msgid "You can not access this project" +msgstr "Vous n'avez pas accès à ce projet" + #: templates/base.html:44 msgid "home" -msgstr "acceuil" +msgstr "accueil" #: templates/base.html:45 msgid "contents" @@ -48,30 +52,46 @@ msgid "Langue" msgstr "Langue" -#: templates/franceculture/embed_popup.html:51 +#: templates/franceculture/embed_popup.html:42 +msgid "popup_player" +msgstr "Code du lecteur" + +#: templates/franceculture/embed_popup.html:42 +msgid "popup_seo_body" +msgstr "Code lecteur et seo" + +#: templates/franceculture/embed_popup.html:42 +msgid "popup_seo_meta" +msgstr "Code lecteur et seo balise meta" + +#: templates/franceculture/embed_popup.html:42 +msgid "popup_links" +msgstr "Liste de liens" + +#: templates/franceculture/embed_popup.html:56 msgid "clik here to see the project content" msgstr "cliquer ici pour voir le contenu du projet" -#: templates/franceculture/workspace.html:49 +#: templates/franceculture/workspace.html:52 #: templates/ldt/ldt_utils/content_list.html:50 msgid "content list" msgstr "Liste des contenus" -#: templates/franceculture/workspace.html:51 -#: templates/franceculture/workspace.html:62 +#: templates/franceculture/workspace.html:54 +#: templates/franceculture/workspace.html:65 #: templates/ldt/ldt_utils/content_list.html:52 #: templates/ldt/ldt_utils/ldt_list.html:79 msgid "search" msgstr "Recherche" -#: templates/franceculture/workspace.html:60 +#: templates/franceculture/workspace.html:63 #: templates/ldt/ldt_utils/ldt_list.html:77 msgid "project list" msgstr "Liste des projets" #: templates/franceculture/partial/contentslist.html:3 #: templates/franceculture/partial/projectslist.html:3 -#: templates/ldt/ldt_utils/create_ldt.html:30 +#: templates/ldt/ldt_utils/create_ldt.html:42 msgid "name" msgstr "Nom" @@ -84,70 +104,112 @@ msgstr "preview" #: templates/franceculture/partial/contentslist.html:21 -#: templates/ldt/ldt_utils/create_content.html:61 +#: templates/ldt/ldt_utils/create_content.html:68 msgid "Create content" msgstr "Créer un Contenu" +#: templates/franceculture/partial/projectslist.html:12 +msgid "open ldt" +msgstr "Ouvrir sous Lignes de Temps" + +#: templates/franceculture/partial/projectslist.html:13 +msgid "copy project" +msgstr "Copier projet" + #: templates/franceculture/partial/projectslist.html:14 +msgid "link json by id" +msgstr "Ouvrir le lecteur augmenté" + +#: templates/franceculture/partial/projectslist.html:17 msgid "Project published, click to unpublish" msgstr "Projet publié, cliquer pour de-publier" -#: templates/franceculture/partial/projectslist.html:16 +#: templates/franceculture/partial/projectslist.html:19 msgid "Project not published, click to publish" msgstr "Projet non publié, cliquer pour publier" -#: templates/franceculture/partial/projectslist.html:20 -msgid "open ldt" -msgstr "Ouvrir sous Lignes de Temps" - -#: templates/franceculture/partial/projectslist.html:21 -msgid "copy project" -msgstr "Copier projet" - -#: templates/franceculture/partial/projectslist.html:22 -msgid "link json by id" -msgstr "Ouvrir le lecteur augmenté" - -#: templates/franceculture/partial/projectslist.html:31 +#: templates/franceculture/partial/projectslist.html:36 msgid "Create project" msgstr "Créer un projet" -#: templates/ldt/ldt_utils/create_content.html:40 +#: templates/ldt/ldt_utils/create_content.html:47 msgid "" "The operation could not be performed because one or more error(s) occurred." "
Please resubmit the content form after making the following changes:" msgstr "" -"opération impossible à cause d'une ou plusieurs erreurs." -"
Veuillez resoumettre le formulaire contenu après avoir fait les " -"changements suivants:" +"opération impossible à cause d'une ou plusieurs erreurs.
Veuillez " +"resoumettre le formulaire contenu après avoir fait les changements suivants:" - -#: templates/ldt/ldt_utils/create_content.html:51 +#: templates/ldt/ldt_utils/create_content.html:58 msgid "" "The operation could not be performed because one or more error(s) occurred." "
Please resubmit the media form after making the following changes:" msgstr "" -"opération impossible à cause d'une ou plusieurs erreurs." -"
Veuillez resoumettre le formulaire media après avoir fait les " -"changements suivants:" +"opération impossible à cause d'une ou plusieurs erreurs.
Veuillez " +"resoumettre le formulaire media après avoir fait les changements suivants:" + +#: templates/ldt/ldt_utils/create_content.html:105 +msgid "media file is being processed please wait." +msgstr "Le fichier média est en cours de traitement. Veullez patienter." + +#: templates/ldt/ldt_utils/create_content.html:109 +#: templates/ldt/ldt_utils/create_ldt.html:59 +#: templates/ldt/ldt_utils/error_confirm.html:48 +msgid "close_cancel" +msgstr "Annuler" +#: templates/ldt/ldt_utils/create_content.html:110 +msgid "delete" +msgstr "Effacer" -#: templates/ldt/ldt_utils/create_ldt.html:23 +#: templates/ldt/ldt_utils/create_content.html:111 +msgid "write" +msgstr "Enregistrer" + +#: templates/ldt/ldt_utils/create_ldt.html:34 +msgid "Update your project" +msgstr "Mettre à jour un projet" + +#: templates/ldt/ldt_utils/create_ldt.html:34 msgid "Create your project" msgstr "Créer un projet" -#: templates/ldt/ldt_utils/create_ldt.html:26 +#: templates/ldt/ldt_utils/create_ldt.html:38 msgid "Title" msgstr "Titre" -#: templates/ldt/ldt_utils/create_ldt.html:28 +#: templates/ldt/ldt_utils/create_ldt.html:40 msgid "List of contents" msgstr "Liste des Médias" -#: templates/ldt/ldt_utils/create_ldt.html:47 -msgid "Create" +#: templates/ldt/ldt_utils/create_ldt.html:61 +msgid "delete_project" +msgstr "Effacer" + +#: templates/ldt/ldt_utils/create_ldt.html:62 +msgid "update_project" +msgstr "Mettre à jour" + +#: templates/ldt/ldt_utils/create_ldt.html:64 +msgid "create_project" msgstr "Créer" +#: templates/ldt/ldt_utils/error_confirm.html:30 +msgid "error" +msgstr "Erreurs" + +#: templates/ldt/ldt_utils/error_confirm.html:30 +msgid "confirm" +msgstr "Confirmer" + +#: templates/ldt/ldt_utils/error_confirm.html:44 +msgid "close_error" +msgstr "fermer" + +#: templates/ldt/ldt_utils/error_confirm.html:49 +msgid "do_delete" +msgstr "Effacer" + #: templates/ldt/user/login_form.html:33 templates/registration/login.html:14 msgid "Log in" msgstr "Connexion" @@ -188,6 +250,9 @@ msgid "Forget password?" msgstr "Mot de passe oublié ?" +#~ msgid "Create" +#~ msgstr "Créer" + #~ msgid "link json by externalid" #~ msgstr "ouvrir le lecteur augmenté" diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/settings.py --- a/web/franceculture/settings.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/franceculture/settings.py Fri Oct 15 12:36:43 2010 +0200 @@ -144,5 +144,5 @@ LOGIN_REDIRECT_URL = BASE_URL + 'franceculture' GLOBAL_LOG_LEVEL = LOG_LEVEL -GLOBAL_LOG_HANDLERS = [logging.FileHandler(LOG_FILE)] +GLOBAL_LOG_HANDLERS = [{'handler':logging.FileHandler(LOG_FILE), 'format':"%(asctime)s - %(levelname)s : %(message)s"}] diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/templates/ldt/ldt_utils/workspace.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/franceculture/templates/ldt/ldt_utils/workspace.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,4 @@ +{% extends "ldt/ldt_utils/workspace_base.html" %} + +{% block title %}France Culture{% endblock %} +{% block base_title %}France Culture{% endblock %} diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/urls.py diff -r 2f978b081c4c -r 9927a619d2b5 web/franceculture/views.py diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/auth/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/auth/__init__.py Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,7 @@ + +def checkAccess(user, obj): + check_meth = getattr(obj, 'checkAccess', False) + if check_meth: + return check_meth(user) + else: + return user.is_staff \ No newline at end of file diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/contentindexer.py --- a/web/ldt/ldt_utils/contentindexer.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/contentindexer.py Fri Oct 15 12:36:43 2010 +0200 @@ -8,19 +8,13 @@ import ldt.utils.xml from django.conf import settings from models import Content -import xml -import xml.dom -import xml.dom.minidom -import xml.dom.ext -import xml.xpath import fnmatch -import Ft import uuid import shutil import lucene from ldt.ldt_utils import STORE from ldt.ldt_utils import ANALYZER -## import lxml.etree +import lxml.etree def Property(func): return property(**func()) @@ -57,52 +51,50 @@ def index_content(self, content): url =content.iri_url() filepath = urllib.urlopen(url) - doc = xml.dom.minidom.parse(filepath) - doc = Ft.Xml.Domlette.ConvertDocument(doc) - + doc = lxml.etree.fromstring(filepath) + self.__writer.deleteDocuments(lucene.Term("iri_id", content.iri_id)) - con = xml.xpath.Context.Context(doc, 1, 1, None) - res = xml.xpath.Evaluate("/iri/body/ensembles/ensemble", context=con) + res = doc.xpath("/iri/body/ensembles/ensemble") for ensemble in res: - ensembleId = ensemble.getAttributeNS(None,u"id") + ensembleId = ensemble.get(None,u"id") - for decoupageNode in ensemble.childNodes: - if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None,u"id") in self.decoupage_blacklist: + for decoupageNode in ensemble.getchildren(): + if decoupageNode.tag != "decoupage" or decoupageNode.get(None,u"id") in self.decoupage_blacklist: continue - decoupId = decoupageNode.getAttributeNS(None,u"id") - res = xml.xpath.Evaluate("elements/element", decoupageNode) + decoupId = decoupageNode.get(None,u"id") + res = decoupageNode.xpath("elements/element") for elementNode in res: doc = lucene.Document() - elementId = elementNode.getAttributeNS(None,u"id") - tags = elementNode.getAttributeNS(None,u"tags") + elementId = elementNode.get(None,u"id") + tags = elementNode.get(None,u"tags") if tags is not None: tags.replace(",", ";") if tags is None or len(tags) == 0: tags = "" - restagnode = xml.xpath.Evaluate("tag/text()", elementNode) + restagnode = elementNode.xpath("tag/text()") for tagnode in restagnode: - tags = tags + " ; " + tagnode.data + tags = tags + " ; " + tagnode.text() if tags is None or len(tags) == 0: tags = "" - restagnode = xml.xpath.Evaluate("tags/tag/text()", elementNode) + restagnode = elementNode.xpath("tags/tag/text()") for tagnode in restagnode: - tags = tags + " ; " + tagnode.data + tags = tags + " ; " + tagnode.text() title = "" - for txtRes in xml.xpath.Evaluate("title/text()", elementNode): - title = title + txtRes.data + for txtRes in elementNode.xpath("title/text()"): + title = title + txtRes.text() abstract = "" - for txtRes in xml.xpath.Evaluate("abstract/text()", elementNode): - abstract = abstract + txtRes.data + for txtRes in elementNode.xpath("abstract/text()"): + abstract = abstract + txtRes.text() doc.add(lucene.Field("iri_id", content.iri_id, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED)) doc.add(lucene.Field("ensemble_id", ensembleId, lucene.Field.Store.YES, lucene.Field.Index.NO)) @@ -164,53 +156,51 @@ def index_project(self, project): # pocketfilms.utils.log.debug("Indexing project : "+str(project.iri_id)) - doc = xml.dom.minidom.parseString(project.ldt) - doc = Ft.Xml.Domlette.ConvertDocument(doc) + doc = lxml.etree.fromstring(project.ldt) self.__writer.deleteDocuments(lucene.Term("iri_id", project.iri_id)) - con = xml.xpath.Context.Context(doc, 1, 1, None) - res = xml.xpath.Evaluate("/iri/annotations/content", context=con) + res = doc.xpath("/iri/annotations/content") for content in res: - contentId = content.getAttributeNS(None,u"id") + contentId = content.get(None,u"id") ensembleId = "ens_perso" - for decoupageNode in content.childNodes: + for decoupageNode in content.getchildren(): # pocketfilms.utils.log.debug("Indexing content decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist)) - if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None,"id") in self.decoupage_blacklist: - continue + if decoupageNode.tag != "decoupage" or decoupageNode.get(None,"id") in self.decoupage_blacklist: + continue - decoupId = decoupageNode.getAttributeNS(None,u"id") - res = xml.xpath.Evaluate("elements/element", decoupageNode) + decoupId = decoupageNode.get(None,u"id") + res = decoupageNode.xpath("elements/element") for elementNode in res: doc = lucene.Document() - elementId = elementNode.getAttributeNS(None,u"id") - tags = elementNode.getAttributeNS(None,u"tags") + elementId = elementNode.get(None,u"id") + tags = elementNode.get(None,u"tags") if tags is not None: tags.replace(",", ";") if tags is None or len(tags) == 0: tags = "" - restagnode = xml.xpath.Evaluate("tag/text()", elementNode) + restagnode = elementNode.xpath("tag/text()") for tagnode in restagnode: - tags = tags + " ; " + tagnode.data + tags = tags + " ; " + tagnode.text() if tags is None or len(tags) == 0: tags = "" - restagnode = xml.xpath.Evaluate("tags/tag/text()", elementNode) + restagnode = elementNode.xpath("tags/tag/text()") for tagnode in restagnode: - tags = tags + " ; " + tagnode.data + tags = tags + " ; " + tagnode.text() title = "" - for txtRes in xml.xpath.Evaluate("title/text()", elementNode): - title = title + txtRes.data + for txtRes in elementNode.xpath("title/text()"): + title = title + txtRes.text() abstract = "" - for txtRes in xml.xpath.Evaluate("abstract/text()", elementNode): - abstract = abstract + txtRes.data + for txtRes in elementNode.xpath("abstract/text()"): + abstract = abstract + txtRes.text() doc.add(lucene.Field("project_id", project.iri_id, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED)) doc.add(lucene.Field("iri_id", contentId, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED)) diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/forms.py --- a/web/ldt/ldt_utils/forms.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/forms.py Fri Oct 15 12:36:43 2010 +0200 @@ -30,7 +30,7 @@ field = forms.ChoiceField([(u"all", u"all"), (u"title", u"title"), (u"abstract", u"resume"), (u"tags", u"tags")]) class AddProjectForm (forms.Form): - title = forms.CharField() + title = forms.CharField(widget=forms.TextInput(attrs={'class':'inputbox required'})) class CopyProjectForm (forms.Form): title = forms.CharField() diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/models.py --- a/web/ldt/ldt_utils/models.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/models.py Fri Oct 15 12:36:43 2010 +0200 @@ -23,9 +23,9 @@ class Media(models.Model): external_id = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('media.external_id')) - external_permalink = models.URLField(max_length=1024, null=True, blank=True, verbose_name=_('content.external_permalink')) - external_publication_url = models.URLField(max_length=1024, null=True, blank=True, verbose_name=_('content.external_publication_url')) - external_src_url = models.URLField(max_length=1024, null=True, blank=True, verbose_name=_('content.external_publication_url')) + external_permalink = models.URLField(max_length=1024, verify_exists=False, null=True, blank=True, verbose_name=_('media.external_permalink')) + external_publication_url = models.URLField(max_length=1024, verify_exists=True, null=True, blank=True, verbose_name=_('media.external_publication_url')) + external_src_url = models.URLField(max_length=1024, verify_exists=False, null=True, blank=True, verbose_name=_('media.external_src_url')) creation_date = models.DateTimeField(auto_now_add=True, verbose_name=_('media.creation_date')) media_creation_date = models.DateTimeField(null=True, blank=True, verbose_name=_('media.media_creation_date')) update_date = models.DateTimeField(auto_now=True, verbose_name=_('media.update_date')) @@ -47,7 +47,7 @@ 'mp3': lambda s: "%s:%s" %("mp3",res_src[:-4]), 'mp4': lambda s: "%s:%s" %("mp4",res_src[:-4]), 'f4v': lambda s: "%s:%s" %("mp4",res_src[:-4]), - }.get(extension, lambda s:s)(res_src) + }.get(extension, lambda s:s)(res_src.lower()) return res_src return locals() @@ -82,12 +82,21 @@ content_creation_date = models.DateTimeField(null=True, blank=True, verbose_name=_('content.content_creation_date')) tags = tagging.fields.TagField(max_length=2048, null=True, blank=True ) media_obj = models.ForeignKey('Media', blank=True, null=True ) + + class Meta: + ordering = ["title"] def get_duration(self): if self.duration is None: doc = lxml.etree.parse(self.iri_file_path()) res = doc.xpath("/iri/body/medias/media[@id='video']/video") - self.duration = int(res[0].get(u'dur') or 0) + if len(res) > 0: + try: + self.duration = int(res[0].get(u'dur',0) or 0) + except: + self.duration = 0 + else: + self.duration = 0 self.save() return self.duration @@ -248,6 +257,10 @@ changed_by = models.CharField(_("changed by"), max_length=70) state = models.IntegerField(choices=STATE_CHOICES, default=1) + class Meta: + ordering = ["title"] + + def __unicode__(self): return unicode(self.id) + u": " + unicode(self.ldt_id) @@ -286,6 +299,13 @@ project.contents.add(content) project.save() return project + + def checkAccess(self, user): + if (user and user.is_staff) or self.state == 2: + return True + else: + return False + class Segment(models.Model): diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/projectindexer.py --- a/web/ldt/ldt_utils/projectindexer.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/projectindexer.py Fri Oct 15 12:36:43 2010 +0200 @@ -4,15 +4,10 @@ import shutil import ldt.utils.xml from ldt import settings -import xml -import xml.dom -import xml.dom.minidom -import xml.dom.ext -import xml.xpath import lucene from ldt.ldt_utils import STORE from ldt.ldt_utils import ANALYZER - +import lxml.etree def Property(func): return property(**func()) @@ -47,68 +42,67 @@ def index_project(self, project): # ldt.utils.log.debug("Indexing project : "+str(project.ldt_id)) - ldt=project.ldt - doc = xml.dom.minidom.parseString(ldt.encode( "utf-8" )) + ldt=project.ldt + doc = lxml.etree.fromstring(ldt.encode( "utf-8" )) self.__writer.deleteDocuments(lucene.Term("ldt_id", project.ldt_id)) - con = xml.xpath.Context.Context(doc, 1, 1, None) - res = xml.xpath.Evaluate("/iri/annotations/content", context=con) + res = doc.xpath("/iri/annotations/content") project.ldt.encode( "utf-8 " ) for content in res: - contentId = content.getAttribute("id") + contentId = content.get("id") - res =xml.xpath.Evaluate("ensemble", content) + res =content.xpath("ensemble") for ensemble in res: - ensembleId = ensemble.getAttribute("id") + ensembleId = ensemble.get("id") - for decoupageNode in ensemble.childNodes: + for decoupageNode in ensemble.getchildren(): # ldt.utils.log.debug("Indexing project decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist)) - if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttribute("id") in self.decoupage_blacklist: + if decoupageNode.tag != "decoupage" or decoupageNode.get("id") in self.decoupage_blacklist: continue - decoupId = decoupageNode.getAttribute("id") - res = xml.xpath.Evaluate("elements/element", decoupageNode) + decoupId = decoupageNode.get("id") + res = decoupageNode.xpath("elements/element") for elementNode in res: doc = lucene.Document() - elementId = elementNode.getAttribute("id") - tags = elementNode.getAttribute("tags") + elementId = elementNode.get("id") + tags = elementNode.get("tags") if tags is not None: tags.replace(",", ";") if tags is None or len(tags) == 0: tags = "" - restagnode = xml.xpath.Evaluate("tag/text()", elementNode) + restagnode = elementNode.xpath("tag/text()") for tagnode in restagnode: - tags = tags + " ; " + tagnode.data + tags = tags + " ; " + tagnode.text() if tags is None or len(tags) == 0: tags = "" - restagnode = xml.xpath.Evaluate("tags/tag/text()", elementNode) + restagnode = elementNode.xpath("tags/tag/text()") for tagnode in restagnode: - tags = tags + " ; " + tagnode.data + tags = tags + " ; " + tagnode.text() title = "" - for txtRes in xml.xpath.Evaluate("title/text()", elementNode): - title = title + txtRes.data + for txtRes in elementNode.xpath("title/text()"): + title = title + txtRes.text() abstract = "" - for txtRes in xml.xpath.Evaluate("abstract/text()", elementNode): - abstract = abstract + txtRes.data + for txtRes in elementNode.xpath("abstract/text()"): + abstract = abstract + txtRes.text() - doc.add(lucene.Field("ldt_id", project.ldt_id, lucene.Field.Store.YES, lucene.Field.Index.UN_TOKENIZED)) - doc.add(lucene.Field("iri_id", contentId, lucene.Field.Store.YES, lucene.Field.Index.UN_TOKENIZED)) + doc.add(lucene.Field("ldt_id", project.ldt_id, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED)) + doc.add(lucene.Field("iri_id", contentId, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED)) doc.add(lucene.Field("ensemble_id", ensembleId, lucene.Field.Store.YES, lucene.Field.Index.NO)) doc.add(lucene.Field("decoupage_id", decoupId, lucene.Field.Store.YES, lucene.Field.Index.NO)) doc.add(lucene.Field("element_id", elementId, lucene.Field.Store.YES, lucene.Field.Index.NO)) - doc.add(lucene.Field("tags", tags, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED)) - doc.add(lucene.Field("title", title, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED)) - doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED)) - doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED)) + doc.add(lucene.Field("tags", tags, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED)) + doc.add(lucene.Field("title", title, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED)) + doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED)) + doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.ANALYZED)) self.__writer.addDocument(doc) - self.__writer.flush() + self.__writer.commit() diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/projectserializer.py --- a/web/ldt/ldt_utils/projectserializer.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/projectserializer.py Fri Oct 15 12:36:43 2010 +0200 @@ -10,15 +10,19 @@ """ class ProjectSerializer: - def __init__(self, project): + def __init__(self, project, from_contents=True, from_display=True): self.project = project + self.parsed = False self.ldt_doc = None self.medias = [] self.annotations = [] self.tags = {} + self.tags_by_id = {} self.annotation_types = [] self.views = [] self.lists = [] + self.serialize_contents = from_contents + self.from_display = from_display def __parse_ensemble(self, ensemble_node, content): @@ -151,6 +155,7 @@ } } self.tags[tag_title] = new_tag + self.tags_by_id[tag_id] = new_tag element_tags.append({"id-ref":tag_id}) if not element_tags: @@ -199,8 +204,7 @@ content = Content.objects.get(iri_id=iri_id) self.__parse_content(content) - res = self.ldt_doc.xpath("/iri/annotations/content") - + res = self.ldt_doc.xpath("/iri/annotations/content") for content_node in res: content_id = content_node.attrib[u"id"] content = Content.objects.get(iri_id=content_id) @@ -209,6 +213,11 @@ continue self.__parse_ensemble(ensemble_node, content) +# res = self.ldt_doc.xpath("/iri/displays/display") +# for display_node in res: +# pass + + self.parsed = True def __parse_content(self, content): @@ -239,11 +248,16 @@ if len(res) > 0: content_date = res[0] - + href = "" + meta_item_value = "" + if content.videopath: + href = content.videopath.rstrip('/') + "/" + content.src + meta_item_value = content.videopath.rstrip('/') + "/" + new_media = { "http://advene.liris.cnrs.fr/ns/frame_of_reference/ms" : "o=0", "id" : content.iri_id, - "href" : content.videopath.rstrip('/') + "/" + content.src, + "href" : href, "unit" : "ms", "origin" : "0", "meta": { @@ -258,25 +272,25 @@ "dc:duration" : content.get_duration(), "item": { "name" : "streamer", - "value": content.videopath.rstrip('/') + "/" + "value": meta_item_value, }, } } self.medias.append(new_media) - - res = doc.xpath("/iri/body/ensembles/ensemble") - - for ensemble_node in res: - self.__parse_ensemble(ensemble_node, content) + if self.serialize_contents: + res = doc.xpath("/iri/body/ensembles/ensemble") + for ensemble_node in res: + self.__parse_ensemble(ensemble_node, content) def serialize_to_cinelab(self): res = {} - self.__parse_ldt() + if not self.parsed: + self.__parse_ldt() project_main_media = "" if len(self.medias) > 0: @@ -321,4 +335,42 @@ res['views'] = self.views # ignored for the moment return res + + def getAnnotations(self, first_cutting=True): + if not self.parsed: + self.__parse_ldt() + + annotations = [] + + current_cutting = None + uri = None + for annot in self.annotations: + if first_cutting and current_cutting and current_cuttings != annot['meta']['id-ref'] : + break + current_cuttings = annot['meta']['id-ref'] + content_id = annot['media'] + content = Content.objects.get(iri_id=content_id) + if annot['tags']: + tags_list = map(lambda tag_entry: self.tags_by_id[tag_entry['id-ref']]['meta']['dc:title'],annot['tags']) + else: + tags_list = [] + begin = int(annot['begin']) + duration = int(annot['end'])-begin + if content.media_obj and content.media_obj.external_publication_url: + uri = "%s#t=%d" % (content.media_obj.external_publication_url, begin) + + + annotations.append({ + 'begin': begin, + 'duration':duration, + 'title':annot['content']['title'], + 'desc':annot['content']['description'], + 'tags': tags_list, + 'id':annot['id'], + 'uri':uri + }) + + return annotations + + diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/embed_popup.html --- a/web/ldt/ldt_utils/templates/ldt/embed_popup.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -{% load i18n %} - - - - - - - - Ligne de Temps - IRI - - - - - - - - - - -
- {% include "ldt/ldt_utils/embed.html" %} -
- -
 
- - -
-{{ player_embed_rendered }}
-
-
- - - {% trans 'clik here to see the project content' %} - -
-		
-		
- - - diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/contentslist.html --- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/contentslist.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -{% load i18n %} -
-{% trans "name" %} -
-
-
- - - {% for content in contents %} - - - - - - {% endfor %} - -
{% trans 'create project' %}
{% trans 'preview media'%}
{{ content.title }}
-
-
- - diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html --- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Fri Oct 15 12:36:43 2010 +0200 @@ -1,4 +1,4 @@ -{% extends "ldt_raw_base.html" %} +{% extends "ldt/ldt_raw_base.html" %} {% load i18n %} {# form of creation of content #} {% load adminmedia %} @@ -23,6 +23,13 @@ +{% endblock %} {% block body %}
-
{% trans "Create your project" %}
+
{% if ldt_id %}{% trans "Update your project" %}{% else %}{% trans "Create your project" %}{% endif %}
{% csrf_token %} + - + {{form.title}}
{% trans "name" %}
@@ -34,7 +46,7 @@ {% for content in contents %} - + {{ content.title }} {% endfor %} @@ -43,8 +55,14 @@
-
- +
+ + {% if ldt_id %} + + + {% else %} + + {% endif %}
diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/embed.html --- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/embed.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -
 
-
-
- diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/embed_popup.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/embed_popup.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,60 @@ +{% load i18n %} + + + + + + + + Ligne de Temps - IRI + + + + + + + + + + + + + +
+ {% include "ldt/ldt_utils/partial/embed_player.html" %} +
+ +
 
+ + +
+
+ +
+
+ +
+ +
{{ embed_rendered.player }}
+
{{ embed_rendered.seo_body }}
+
{{ embed_rendered.seo_meta }}
+
+ + +
+ + {% trans 'clik here to see the project content' %} + + + + diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/error_confirm.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/error_confirm.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,54 @@ +{% extends "ldt/ldt_raw_base.html" %} + +{% load i18n %} {# form of creation of content #} + +{% block js_import %} + {{ block.super }} +{% endblock %} + +{% block css_import %} + {{ block.super }} + {{ content_form.media.css }} + + +{% endblock %} + + +{% block js_declaration %} + +{% endblock %} + +{% block body %} + +
+
{% if errors|length > 0 %}{% trans "error" %}{% else %}{% trans "confirm" %}{% endif %}
+
+ {{ message }} + {% if errors|length > 0 %} +
    + {% for error_msg in errors %} +
  • {{ error_msg }}
  • + {% endfor %} +
+ {% endif %} +
+ +
+{% if errors|length > 0 %} + +{% else %} +
+ {% csrf_token %} + + +
+{% endif %} +
+ +{% endblock %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/ldt_list.html --- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/ldt_list.html Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/ldt_list.html Fri Oct 15 12:36:43 2010 +0200 @@ -1,4 +1,4 @@ -{% extends "ldt_base.html" %} +{% extends "ldt/ldt_base.html" %} {% load i18n %} {% block js_import %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/contentslist.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/contentslist.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,23 @@ +{% load i18n %} +
+{% trans "name" %} +
+
+
+ + + {% for content in contents %} + + + + + + {% endfor %} + +
{% trans 'create project' %}
{% trans 'preview media'%}
{{ content.title|default:"_" }}
+
+
+ + diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_links.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_links.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,9 @@ +{% spaceless %} + +{% endspaceless %} \ No newline at end of file diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,27 @@ +{% spaceless %} +{% load i18n %} +
+
 
+
+
+ +
+{% endspaceless %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_seo_body.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_seo_body.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,9 @@ +{% spaceless %} + +{% endspaceless %} \ No newline at end of file diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_seo_meta.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_seo_meta.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,3 @@ +{% spaceless %} + +{% endspaceless %} \ No newline at end of file diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,37 @@ +{% load i18n %} +
+{% trans "name" %} +
+
+
+ + +{% for project in projects %} + + {% url ldt.ldt_utils.views.project_json_id project.ldt_id as json_url_id %} + + + + + + +{% endfor %} + +
{% trans 'open ldt' %}
{% trans 'copy project' %}
{% trans 'link json by id' %}
+ {% ifequal project.state 2 %} + {% trans 'Project published, click to unpublish' %} + {% else %} + {% trans 'Project not published, click to publish' %} + {% endifequal %} + + {% ifequal project.state 2 %} + {{ project.title }} + {% else %} + {{ project.title }} + {% endifequal %} +
+
+
+ diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/projectslist.html --- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/projectslist.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -{% load i18n %} -
-{% trans "name" %} -
-
-
- - -{% for project in projects %} - - {% url ldt.ldt_utils.views.project_json_id project.ldt_id as json_url_id %} - - - - - - -{% endfor %} - -
- {% ifequal project.state 2 %} - {% trans 'Project published, click to unpublish' %} - {% else %} - {% trans 'Project not published, click to publish' %} - {% endifequal %} -
-
{% trans 'open ldt' %}
{% trans 'copy project' %}
{% trans 'link json by id' %}
{{ project.title }}
-
-
- diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html --- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html Fri Oct 15 12:36:43 2010 +0200 @@ -1,4 +1,4 @@ -{% extends "base.html" %} {% block content %} +{% extends "ldt/base.html" %} {% block content %}
+{% endblock %} + + +{% block js_declaration %} +{{block.super}} + + +{% endblock %} + +{% block css_import %} +{{block.super}} + +{% endblock %} + +{% block content %} +
+
+
+
{% trans "content list" %}
+
+
loader
+
+
+
+ {% include "ldt/ldt_utils/partial/contentslist.html" %} +
+
+
+
+
{% trans "project list" %}
+
+
loader
+
+
+
+ {% include "ldt/ldt_utils/partial/projectslist.html" %} +
+
+
+{% endblock %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/templates/ldt/workspace.html --- a/web/ldt/ldt_utils/templates/ldt/workspace.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -{% extends "ldt_base.html" %} -{% load i18n %} - -{% block js_import %} -{{block.super}} - -{% endblock %} - - -{% block js_declaration %} -{{block.super}} - - -{% endblock %} - -{% block css_import %} -{{block.super}} - -{% endblock %} - -{% block content %} -
-
-
-
{% trans "content list" %}
-
-
loader
-
-
-
- {% include "ldt/ldt_utils/contentslist.html" %} -
-
-
-
-
{% trans "project list" %}
-
-
loader
-
-
-
- {% include "ldt/ldt_utils/projectslist.html" %} -
-
-
-{% endblock %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/tests.py --- a/web/ldt/ldt_utils/tests.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/tests.py Fri Oct 15 12:36:43 2010 +0200 @@ -38,142 +38,142 @@ class UtilsTest(unittest.TestCase): def setUp(self): - self.user = Owner() - self.user.username = "toto" - self.LU = LdtUtils() - - self.project = Project(title="titleproj1", owner=self.user) - self.project.ldt = ' CA: prof et admin <abstract/> <audio source=""/> <tags/> </element> <element id="s_0050F043-3AD2-0A7C-6699-D2A03A1EBA02" begin="5052858" dur="124407" author="" date="2010/09/02" color="10053375" src=""> <title>conseil de classe Reprise de la figure precedente TC: prof et admin Conseil de classe conseil de classe Reprise de la figure precedente Bout a bout 1 ' - self.project.id = "11" - self.project.ldt_id = str(uuid.uuid1()) - self.project.save() - - self.projectcopy = Project(title="the2ndproject") - self.projectcopy.id="22" + self.user = Owner() + self.user.username = "toto" + self.LU = LdtUtils() + + self.project = Project(title="titleproj1", owner=self.user) + self.project.ldt = ' CA: prof et admin <abstract/> <audio source=""/> <tags/> </element> <element id="s_0050F043-3AD2-0A7C-6699-D2A03A1EBA02" begin="5052858" dur="124407" author="" date="2010/09/02" color="10053375" src=""> <title>conseil de classe Reprise de la figure precedente TC: prof et admin Conseil de classe conseil de classe Reprise de la figure precedente Bout a bout 1 ' + self.project.id = "11" + self.project.ldt_id = str(uuid.uuid1()) + self.project.save() + + self.projectcopy = Project(title="the2ndproject") + self.projectcopy.id="22" def tearDown(self): - self.project.delete() - self.projectcopy.delete() - #self.cont1.delete() - #self.cont2.delete() + self.project.delete() + self.projectcopy.delete() + #self.cont1.delete() + #self.cont2.delete() def test_generate_ldt(self): - self.cont1 = Content(iriurl="id1/iriurl1") - self.cont1.iri_id = "id1" - self.cont1.save() - - self.cont2 = Content(iriurl="id2/iriurl2") - self.cont2.iri_id = "id2" - self.cont2.save() - - self.project.contents.add(self.cont1,self.cont2) - - f=tempfile.TemporaryFile(mode='r+') - self.LU.generateLdt(Content.objects.all(),f) - f.seek(0) - ldoc = lxml.etree.parse(f) - self.assertEqual(ldoc.xpath("/iri/displays/display/content")[9].get("id"),self.cont2.iri_id) - self.assertEqual(ldoc.xpath("/iri/medias/media")[8].get("id"), self.cont1.iri_id) - f.close() + self.cont1 = Content(iriurl="id1/iriurl1") + self.cont1.iri_id = "id1" + self.cont1.save() + + self.cont2 = Content(iriurl="id2/iriurl2") + self.cont2.iri_id = "id2" + self.cont2.save() + + self.project.contents.add(self.cont1,self.cont2) + + f=tempfile.TemporaryFile(mode='r+') + self.LU.generateLdt(Content.objects.all(),f) + f.seek(0) + ldoc = lxml.etree.parse(f) + self.assertEqual(ldoc.xpath("/iri/displays/display/content")[9].get("id"),self.cont2.iri_id) + self.assertEqual(ldoc.xpath("/iri/medias/media")[8].get("id"), self.cont1.iri_id) + f.close() def test_generate_init(self): - self.cont3 = Content(iriurl="id3/iriurl1") - self.cont3.iri_id = "id3" - self.cont3.save() - - self.cont4 = Content(iriurl="id4/iriurl2") - self.cont4.iri_id = "id4" - self.cont4.save() - - self.project.contents.add(self.cont3,self.cont4) - ldoc = self.LU.generateInit(None,None) - self.assertEqual(ldoc.xpath("/iri/files/init")[0].tag, "init") - self.assertEqual(ldoc.xpath("/iri/files/library")[0].tag, "library") - self.assertEqual(ldoc.xpath("/iri/files/init/file")[0].get("video"), settings.STREAM_URL) + self.cont3 = Content(iriurl="id3/iriurl1") + self.cont3.iri_id = "id3" + self.cont3.save() + + self.cont4 = Content(iriurl="id4/iriurl2") + self.cont4.iri_id = "id4" + self.cont4.save() + + self.project.contents.add(self.cont3,self.cont4) + ldoc = self.LU.generateInit(None,None) + self.assertEqual(ldoc.xpath("/iri/files/init")[0].tag, "init") + self.assertEqual(ldoc.xpath("/iri/files/library")[0].tag, "library") + self.assertEqual(ldoc.xpath("/iri/files/init/file")[0].get("video"), settings.STREAM_URL) def test_create_ldt(self): - self.cont5 = Content(iriurl="id5/iriurl1") - self.cont5.iri_id = "id5" - self.cont5.save() - - self.cont6 = Content(iriurl="id6/iriurl2") - self.cont6.iri_id = "id6" - self.cont6.save() - - self.project.contents.add(self.cont5,self.cont6) - self.project.ldt="" - create_ldt(self.project, self.user) - ldt = lxml.etree.fromstring(self.project.ldt) - self.assertEqual(ldt.xpath("/iri")[0].tag,"iri") - self.assertEqual(ldt.xpath("/iri/project")[0].get("title"), self.project.title) - self.assertEqual(ldt.xpath("/iri/medias/media")[0].get("src"), self.cont5.iri_url()) - self.assertEqual(ldt.xpath("/iri/medias/media")[1].get("id"), self.cont6.iri_id) + self.cont5 = Content(iriurl="id5/iriurl1") + self.cont5.iri_id = "id5" + self.cont5.save() + + self.cont6 = Content(iriurl="id6/iriurl2") + self.cont6.iri_id = "id6" + self.cont6.save() + + self.project.contents.add(self.cont5,self.cont6) + self.project.ldt="" + create_ldt(self.project, self.user) + ldt = lxml.etree.fromstring(self.project.ldt) + self.assertEqual(ldt.xpath("/iri")[0].tag,"iri") + self.assertEqual(ldt.xpath("/iri/project")[0].get("title"), self.project.title) + self.assertEqual(ldt.xpath("/iri/medias/media")[0].get("src"), self.cont5.iri_url()) + self.assertEqual(ldt.xpath("/iri/medias/media")[1].get("id"), self.cont6.iri_id) def test_copy_ldt(self): - self.cont7 = Content(iriurl="id7/iriurl1") - self.cont7.iri_id = "id7" - self.cont7.save() - - self.cont8 = Content(iriurl="id8/iriurl2") - self.cont8.iri_id = "id8" - self.cont8.save() - - self.project.contents.add(self.cont7,self.cont8) - copy_ldt(self.project, self.projectcopy, self.user) - ldt1=lxml.etree.fromstring(self.project.ldt) - ldt2=lxml.etree.fromstring(self.projectcopy.ldt) - self.assertTrue(ldt1.xpath("/iri/project")[0].get("id")!= ldt2.xpath("/iri/project")[0].get("id")) - self.assertEqual(ldt1.xpath("/iri/medias/media")[0].get("id"),ldt2.xpath("/iri/medias/media")[0].get("id")) - self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble")[0].get("title"),ldt2.xpath("/iri/annotations/content/ensemble")[0].get("title")) - self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble/decoupage")[0].get("id"),ldt2.xpath("/iri/annotations/content/ensemble/decoupage")[0].get("id")) - self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble/decoupage/title")[1].text,ldt2.xpath("/iri/annotations/content/ensemble/decoupage/title")[1].text.strip("\n\t")) + self.cont7 = Content(iriurl="id7/iriurl1") + self.cont7.iri_id = "id7" + self.cont7.save() + + self.cont8 = Content(iriurl="id8/iriurl2") + self.cont8.iri_id = "id8" + self.cont8.save() + + self.project.contents.add(self.cont7,self.cont8) + copy_ldt(self.project, self.projectcopy, self.user) + ldt1=lxml.etree.fromstring(self.project.ldt) + ldt2=lxml.etree.fromstring(self.projectcopy.ldt) + self.assertTrue(ldt1.xpath("/iri/project")[0].get("id")!= ldt2.xpath("/iri/project")[0].get("id")) + self.assertEqual(ldt1.xpath("/iri/medias/media")[0].get("id"),ldt2.xpath("/iri/medias/media")[0].get("id")) + self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble")[0].get("title"),ldt2.xpath("/iri/annotations/content/ensemble")[0].get("title")) + self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble/decoupage")[0].get("id"),ldt2.xpath("/iri/annotations/content/ensemble/decoupage")[0].get("id")) + self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble/decoupage/title")[1].text,ldt2.xpath("/iri/annotations/content/ensemble/decoupage/title")[1].text.strip("\n\t")) def test_create_empty_iri(self): - self.cont9 = Content(iriurl="id9/iriurl1") - self.cont9.iri_id = "id9" - self.cont9.save() - - self.cont10 = Content(iriurl="id10/iriurl2") - self.cont10.iri_id = "id10" - self.cont10.save() - - self.project.contents.add(self.cont9,self.cont10) - tmp = tempfile.TemporaryFile(mode='r+') - create_empty_iri(tmp, self.cont9, "admin") - tmp.seek(0) - ldoc = lxml.etree.parse(tmp) - self.assertEqual(ldoc.xpath("/iri/head/meta")[0].get("content"), self.cont9.iri_id) - self.assertEqual(ldoc.xpath("/iri/body/medias/media/video")[0].get("id"), self.cont9.iri_id) - tmp.close() - + self.cont9 = Content(iriurl="id9/iriurl1") + self.cont9.iri_id = "id9" + self.cont9.save() + + self.cont10 = Content(iriurl="id10/iriurl2") + self.cont10.iri_id = "id10" + self.cont10.save() + + self.project.contents.add(self.cont9,self.cont10) + tmp = tempfile.TemporaryFile(mode='r+') + create_empty_iri(tmp, self.cont9, "admin") + tmp.seek(0) + ldoc = lxml.etree.parse(tmp) + self.assertEqual(ldoc.xpath("/iri/head/meta")[0].get("content"), self.cont9.iri_id) + self.assertEqual(ldoc.xpath("/iri/body/medias/media/video")[0].get("id"), self.cont9.iri_id) + tmp.close() + class ViewsTest(unittest.TestCase): def setUp(self): - self.project = Project() - self.project.id = "121" - self.project.save() + self.project = Project() + self.project.id = "121" + self.project.save() self.project.ldt = ' CA: prof et admin <abstract/> <audio source=""/> <tags/> </element> <element id="s_0050F043-3AD2-0A7C-6699-D2A03A1EBA02" begin="5052858" dur="124407" author="" date="2010/09/02" color="10053375" src=""> <title>conseil de classe Reprise de la figure precedente TC: prof et admin Conseil de classe conseil de classe Reprise de la figure precedente Bout a bout 1 ' - - self.cont1 = Content(iriurl="/laurentcantet_entrelesmurs/iriurl1") - self.cont1.iri_id = 'laurentcantet_entrelesmurs' - self.cont1.save() - - self.cont2 = Content(iriurl="/content_notinldt/iriurl2") - self.cont2.iri_id = 'content_notinldt' - self.cont2.save() - - self.project.contents.add(self.cont1, self.cont2) + + self.cont1 = Content(iriurl="/laurentcantet_entrelesmurs/iriurl1") + self.cont1.iri_id = 'laurentcantet_entrelesmurs' + self.cont1.save() + + self.cont2 = Content(iriurl="/content_notinldt/iriurl2") + self.cont2.iri_id = 'content_notinldt' + self.cont2.save() + + self.project.contents.add(self.cont1, self.cont2) def tearDown(self): - self.project.delete() - ##self.cont1.delete() - ##self.cont2.delete() + self.project.delete() + ##self.cont1.delete() + ##self.cont2.delete() - def test_get_attrib(self): - get_attrib(self.project) - ldoc = lxml.etree.fromstring(self.project.ldt) - self.assertEqual(self.project.title, ldoc.xpath("/iri/project")[0].get("title")) - self.assertEqual(ldoc.xpath("/iri/medias/media")[0].get('id'), self.cont1.iri_id) - self.assertTrue(self.cont2.iri_id not in self.project.contents.all()) +# def test_get_attrib(self): +# get_attrib(self.project) +# ldoc = lxml.etree.fromstring(self.project.ldt) +# self.assertEqual(self.project.title, ldoc.xpath("/iri/project")[0].get("title")) +# self.assertEqual(ldoc.xpath("/iri/medias/media")[0].get('id'), self.cont1.iri_id) +# self.assertTrue(self.cont2.iri_id not in self.project.contents.all()) diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/urls.py --- a/web/ldt/ldt_utils/urls.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/urls.py Fri Oct 15 12:36:43 2010 +0200 @@ -18,11 +18,13 @@ url(r'^search/loading/$', 'views.loading'), url(r'^create/(?P.*)$', 'views.create_project'), url(r'^copy/(?P.*)$', 'views.copy_project'), + url(r'^update/(?P.*)$', 'views.update_project'), url(r'^cljson/id/(?P.*)$', 'views.project_json_id'), url(r'^cljson/externalid/(?P.*)$', 'views.project_json_externalid'), - url(r'^filterprojects/(?P\w*)/(?Ptrue|false)/(?P\d)$', "views.projectsfilter", ), + url(r'^rdf/id/(?P.*)$', 'views.project_annotations_rdf'), url(r'^/?$', "views.workspace", name="root-view"), - url(r'^filtercontents/(?P\w*)/$', "views.contentsfilter", ), + url(r'^filterprojects/_(?P[\w\%\_\-\+]*?)/(?Ptrue|false)/(?P\d)$', "views.projectsfilter", ), + url(r'^filtercontents/_(?P[\w\%\_\-\+]*?)/$', "views.contentsfilter", ), (r'^embedpopup/?$', "views.popup_embed"), ) diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/utils.py --- a/web/ldt/ldt_utils/utils.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/utils.py Fri Oct 15 12:36:43 2010 +0200 @@ -36,7 +36,7 @@ queryParser.setDefaultOperator(lucene.QueryParser.Operator.AND) queryObj = queryParser.parse(query) hits = indexSearcher.search(queryObj, settings.LDT_MAX_SEARCH_NUMBER) - + res = [] for hit in hits.scoreDocs: doc = indexSearcher.doc(hit.doc) @@ -44,146 +44,146 @@ indexSearcher.close() return res - def queryAll(self, query): + def queryAll(self, query): return self.query("all", query) class LdtUtils(object): def generateLdt(self, contentList, file, title = u"", author=u"IRI Web", web_url=u"", media_url="", startSegment = None, contributions=None): - iri = lxml.etree.Element(u'iri') - doc = lxml.etree.ElementTree(iri) - - project = lxml.etree.SubElement(iri, u'project') - project.set(u"id",unicode(str(uuid.uuid1()))) + iri = lxml.etree.Element(u'iri') + doc = lxml.etree.ElementTree(iri) + + project = lxml.etree.SubElement(iri, u'project') + project.set(u"id",unicode(str(uuid.uuid1()))) project.set(u"title",unicode(title)) - project.set(u"user",author) - project.set(u"abstract",u"") - - medias = lxml.etree.SubElement(iri, u"medias") - for content in contentList: - videopath = unicode(settings.STREAM_URL) - if content.videopath : - videopath = unicode(content.videopath) - media = lxml.etree.SubElement(medias, "media") - media.set(u"id",content.iri_id) - media.set(u"src",content.iri_url(web_url)) - media.set(u"video",videopath) + project.set(u"user",author) + project.set(u"abstract",u"") + + medias = lxml.etree.SubElement(iri, u"medias") + for content in contentList: + videopath = unicode(settings.STREAM_URL) + if content.videopath : + videopath = unicode(content.videopath) + media = lxml.etree.SubElement(medias, "media") + media.set(u"id",content.iri_id) + media.set(u"src",content.iri_url(web_url)) + media.set(u"video",videopath) media.set(u"pict",u"") media.set(u"extra",u"") - - if contributions is None: - contributions = [] - annotations_nodes = {} - for contrib in contributions: - ldtdoc = lxml.etree.fromstring(contrib.ldtproject.ldt.encode("utf-8")) - res = ldtdoc.xpath("/iri/annotations/content") - - for content in res: - contentid = content.get("id") - if annotations_nodes.has_key(contentid): - contentnode = annotations_nodes[contentid] - else: - contentnode = {"id":contentid, "ensembles":[]} - annotations_nodes[contentid]=contentnode - for ens in content.childNodes: - if ens.tag.endswith("ensemble"): - contentnode["ensembles"].append(ens.tag) - - - if len(annotations_nodes) > 0: - annotations = lxml.etree.SubElement(iri, "annotations") + + if contributions is None: + contributions = [] + annotations_nodes = {} + for contrib in contributions: + ldtdoc = lxml.etree.fromstring(contrib.ldtproject.ldt.encode("utf-8")) + res = ldtdoc.xpath("/iri/annotations/content") + + for content in res: + contentid = content.get("id") + if annotations_nodes.has_key(contentid): + contentnode = annotations_nodes[contentid] + else: + contentnode = {"id":contentid, "ensembles":[]} + annotations_nodes[contentid]=contentnode + for ens in content.childNodes: + if ens.tag.endswith("ensemble"): + contentnode["ensembles"].append(ens.tag) + + + if len(annotations_nodes) > 0: + annotations = lxml.etree.SubElement(iri, "annotations") + for content in contentList: + if content.content_base.iri_id in annotations_nodes: + contentnode = annotations_nodes[content.content_base.iri_id] + if contentnode is not None: + if len(contentnode["ensembles"])>0: + content = lxml.etree.SubElement(annotation, "content") + content.set("id",contentnode["id"]) + content.text = u"" + else: + content = lxml.etree.SubElement(annotation, "content") + content.set("id",contentnode["id"]) + + else: + annotations = lxml.etree.SubElement(iri, "annotations") + + + displays = lxml.etree.SubElement(iri, "displays") + if len(contentList) > 0: + display = lxml.etree.SubElement(displays, "display") + display.set(u"id",u"0") + display.set(u"title",u"generated") + display.set(u"idsel",contentList[0].iri_id) + display.set(u"tc",u"0") for content in contentList: - if content.content_base.iri_id in annotations_nodes: - contentnode = annotations_nodes[content.content_base.iri_id] - if contentnode is not None: - if len(contentnode["ensembles"])>0: - content = lxml.etree.SubElement(annotation, "content") - content.set("id",contentnode["id"]) - content.text = u"" - else: - content = lxml.etree.SubElement(annotation, "content") - content.set("id",contentnode["id"]) - - else: - annotations = lxml.etree.SubElement(iri, "annotations") - - - displays = lxml.etree.SubElement(iri, "displays") - if len(contentList) > 0: - display = lxml.etree.SubElement(displays, "display") - display.set(u"id",u"0") - display.set(u"title",u"generated") - display.set(u"idsel",contentList[0].iri_id) - display.set(u"tc",u"0") - for content in contentList: - contentd = lxml.etree.SubElement(display,"content") - contentd.set(u"id",content.iri_id) + contentd = lxml.etree.SubElement(display,"content") + contentd.set(u"id",content.iri_id) filepath = urllib.urlopen(content.iri_url()) - - udoc = lxml.etree.parse(filepath) - res = udoc.xpath("/iri/body/ensembles/ensemble/decoupage") + + udoc = lxml.etree.parse(filepath) + res = udoc.xpath("/iri/body/ensembles/ensemble/decoupage") for decoupagenode in res: - decoupage_id = decoupagenode.getAttribute(u"id") - ensemble_id = decoupagenode.parentNode.getAttribute(u"id") - decoupage_id = decoupagenode.get(u"id") - ensemble_id = decoupagenode.getparent().get(u"id") - decoupage = lxml.etree.SubElement(content,"decoupage") - decoupage.set(u"id",decoupage_id) - decoupage.set(u"idens",ensemble_id) + decoupage_id = decoupagenode.get(u"id") + ensemble_id = decoupagenode.getparent().get(u"id") + decoupage_id = decoupagenode.get(u"id") + ensemble_id = decoupagenode.getparent().get(u"id") + decoupage = lxml.etree.SubElement(contentd,"decoupage") + decoupage.set(u"id",decoupage_id) + decoupage.set(u"idens",ensemble_id) if startSegment is not None: - activeSegment = lxml.etree.SubElement(display,"activeSegment") - idas = lxml.etree.SubElement(activeSegment,"id") - idas.set(u"idctt",startSegment["idcontent"]) + activeSegment = lxml.etree.SubElement(display,"activeSegment") + idas = lxml.etree.SubElement(activeSegment,"id") + idas.set(u"idctt",startSegment["idcontent"]) idas.set(u"idens" ,startSegment["idgroup"]) idas.set(u"idcut",startSegment["idcutting"]) idas.set(u"idseg",startSegment["idsegment"]) - - edits = lxml.etree.SubElement(iri, "edits") - - doc.write(file, pretty_print=True) + + edits = lxml.etree.SubElement(iri, "edits") + + doc.write(file, pretty_print=True) def generateInit(self, url, method, search=None): - - iri = lxml.etree.Element('iri') - impl = lxml.etree.ElementTree(iri) + + iri = lxml.etree.Element('iri') + impl = lxml.etree.ElementTree(iri) - elementFiles = lxml.etree.SubElement(iri,'files') - elementInit = lxml.etree.SubElement(elementFiles, 'init') - elementfile = lxml.etree.SubElement(elementInit, 'file') + elementFiles = lxml.etree.SubElement(iri,'files') + elementInit = lxml.etree.SubElement(elementFiles, 'init') + elementfile = lxml.etree.SubElement(elementInit, 'file') - elementfile.set('src',settings.WEB_URL + django.core.urlresolvers.reverse(method, args=url)) - elementfile.set('display', '1') - if(search): - elementfile.set("segsel",settings.WEB_URL + django.core.urlresolvers.reverse(search, args=url)) + elementfile.set('src',settings.WEB_URL + django.core.urlresolvers.reverse(method, args=url)) + elementfile.set('display', '1') + if(search): + elementfile.set("segsel",settings.WEB_URL + django.core.urlresolvers.reverse(search, args=url)) # /*chemin video : tant que le serveur de media n'est pas up, */ - elementfile.set('video', settings.STREAM_URL) - elementfile.set('pict', "") - elementfile.set('extra', "") + elementfile.set('video', settings.STREAM_URL) + elementfile.set('pict', "") + elementfile.set('extra', "") - elementRecent = lxml.etree.SubElement(elementFiles, 'recent') - elementLibrary = lxml.etree.SubElement(elementFiles, 'library') + elementRecent = lxml.etree.SubElement(elementFiles, 'recent') + elementLibrary = lxml.etree.SubElement(elementFiles, 'library') username = '' id = '' - elementUser = lxml.etree.SubElement(iri, 'user') - elementUser.set('name', username) - elementUser.set('id', id) + elementUser = lxml.etree.SubElement(iri, 'user') + elementUser.set('name', username) + elementUser.set('id', id) return iri def create_ldt(project, user): + """create xml""" + contentList = project.contents.all() - """create xml""" - # create a dom iri = lxml.etree.Element('iri') doc = lxml.etree.ElementTree(iri) @@ -203,16 +203,16 @@ for content in contentList: if not idsel: idsel = content.iri_id - elementMedia = lxml.etree.SubElement(elementMedias, 'media') - elementMedia.set('id', content.iri_id) - elementMedia.set('src', content.iri_url()) + elementMedia = lxml.etree.SubElement(elementMedias, 'media') + elementMedia.set('id', content.iri_id) + elementMedia.set('src', content.iri_url()) if content.videopath and content.videopath !="": - elementMedia.set('video', content.videopath) + elementMedia.set('video', content.videopath) else: - elementMedia.set('video', settings.STREAM_URL) - elementMedia.set('pict', "") - elementMedia.set('extra', "") + elementMedia.set('video', settings.STREAM_URL) + elementMedia.set('pict', "") + elementMedia.set('extra', "") if not idsel: idsel = "" @@ -234,8 +234,8 @@ #node content for content in contentList: - elementContent = lxml.etree.SubElement(elementDisplay, 'content') - elementContent.set('id', content.iri_id) + elementContent = lxml.etree.SubElement(elementDisplay, 'content') + elementContent.set('id', content.iri_id) if not 'http' in content.iriurl: #eg: "iiiielizabethrosse/ENMI08-III_elizabethrosse.iri" @@ -243,18 +243,17 @@ else: url =content.iriurl file = urllib.urlopen(url) - doc = lxml.etree.parse(file) - res = doc.xpath("/iri/body/ensembles/ensemble/decoupage") + doc = lxml.etree.parse(file) + res = doc.xpath("/iri/body/ensembles/ensemble/decoupage") - - #node decoupage + #node decoupage for decoupagenode in res: - decoupage_id = decoupagenode.attrib(u"id") - parent= decoupagenode.getparent() - ensemble_id = parent.attrib(u"id") - elementDecoupage = etree.SubElement(elementContent, 'decoupage') - elementDecoupage.set('idens', ensemble_id) - elementDecoupage.set('id', decoupage_id) + decoupage_id = decoupagenode.get(u"id") + parent= decoupagenode.getparent() + ensemble_id = parent.get(u"id") + elementDecoupage = lxml.etree.SubElement(elementContent, 'decoupage') + elementDecoupage.set('idens', ensemble_id) + elementDecoupage.set('id', decoupage_id) #node edits elementEdits = lxml.etree.SubElement(iri, 'edits') @@ -280,10 +279,10 @@ ldt = lxml.etree.fromstring(project.ldt.encode("utf-8")) res = ldt.xpath("/iri/project") for elementProject in res: - elementProject.set('abstract', "") - elementProject.set('title', new_project.title) - elementProject.set('user', user.username) - elementProject.set('id', new_project.ldt_id) + elementProject.set('abstract', "") + elementProject.set('title', new_project.title) + elementProject.set('user', user.username) + elementProject.set('id', new_project.ldt_id) new_project.ldt = lxml.etree.tostring(ldt, pretty_print=True) diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/ldt_utils/views.py --- a/web/ldt/ldt_utils/views.py Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/ldt_utils/views.py Fri Oct 15 12:36:43 2010 +0200 @@ -1,32 +1,45 @@ -import django.core.urlresolvers -from django.http import HttpResponse, HttpResponseRedirect -from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 +from contentindexer import * +from django.conf import settings +from django.contrib.auth.decorators import login_required +from django.core import serializers +from django.core.urlresolvers import reverse +from django.db.models import Q +from django.forms.util import ErrorList +from django.http import HttpResponse, HttpResponseRedirect, \ + HttpResponseForbidden, HttpResponseServerError +from django.shortcuts import render_to_response, get_object_or_404, \ + get_list_or_404 from django.template import RequestContext -from django.core.urlresolvers import reverse -from django.contrib.auth.decorators import login_required -from django.conf import settings -from django.core import serializers +from django.template.loader import render_to_string from django.utils import simplejson from django.utils.html import escape +from django.utils.translation import ugettext as _, ungettext from fileimport import * -from forms import LdtImportForm, LdtAddForm, SearchForm, AddProjectForm, CopyProjectForm, ContentForm, MediaForm +from forms import LdtImportForm, LdtAddForm, SearchForm, AddProjectForm, \ + CopyProjectForm, ContentForm, MediaForm from ldt.core.models import Owner +from ldt.ldt_utils.models import Content, Project, Owner +from ldt.ldt_utils.projectserializer import ProjectSerializer +from ldt.ldt_utils.utils import boolean_convert +from lxml import etree +from lxml.html import fromstring, fragment_fromstring from models import * -from utils import * -from contentindexer import * from projectserializer import * from string import Template +from urllib2 import urlparse +from utils import * +import StringIO +import base64 import cgi -import uuid -import base64 +import django.core.urlresolvers +import ldt.auth as ldt_auth +import ldt.utils.path as ldt_utils_path +import logging import lucene +import lxml.etree import tempfile import urllib2 -from urllib2 import urlparse -from jogging import logging -import lxml.etree -from django.db.models import Q -from django.template.loader import render_to_string +import uuid @login_required @@ -39,24 +52,36 @@ project_list = Project.objects.all() # render list - return render_to_response("ldt/workspace.html", + return render_to_response("ldt/ldt_utils/workspace.html", {'contents': content_list, 'projects': project_list}, context_instance=RequestContext(request)) + def popup_embed(request): json_url = request.GET.get("json_url") player_id = request.GET.get("player_id") + ldt_id = request.GET.get("ldt_id") - embed_rendered = escape(render_to_string('ldt/ldt_utils/embed.html', {'json_url':json_url,'player_id':player_id}, context_instance=RequestContext(request))) + project = Project.objects.get(ldt_id=ldt_id); + if not ldt_auth.checkAccess(request.user, project): + return HttpResponseForbidden(_("You can not access this project")) + + ps = ProjectSerializer(project, from_contents=False, from_display=True) + annotations = ps.getAnnotations(first_cutting=True) - return render_to_response("ldt/embed_popup.html", - {'json_url':json_url,'player_id':player_id, 'player_embed_rendered':embed_rendered}, + embed_rendered = dict((typestr, + (lambda s:escape(lxml.etree.tostring(fragment_fromstring(render_to_string("ldt/ldt_utils/partial/embed_%s.html"%(s), {'json_url':json_url,'player_id':player_id, 'annotations':annotations, 'ldt_id': ldt_id}, context_instance=RequestContext(request))),pretty_print=True)))(typestr)) + for typestr in ('player','seo_body', 'seo_meta', 'links') ) + + return render_to_response("ldt/ldt_utils/embed_popup.html", + {'json_url':json_url,'player_id':player_id, 'embed_rendered':embed_rendered, 'annotations':annotations}, context_instance=RequestContext(request)) + @login_required def projectsfilter(request, filter, is_owner=False, status=0): @@ -76,34 +101,39 @@ if status > 0: query &= Q(state=status) - if filter and filter != "_": + if filter: + if len(filter) > 0 and filter[0] == '_': + filter = filter[1:] query &= Q(title__icontains=filter) project_list = Project.objects.filter(query) - return render_to_response("ldt/ldt_utils/projectslist.html", + return render_to_response("ldt/ldt_utils/partial/projectslist.html", {'projects': project_list}, context_instance=RequestContext(request)) + + + + @login_required def contentsfilter(request, filter): - if filter == "_": - filter = "" + if filter and len(filter) > 0 and filter[0] == '_': + filter = filter[1:] + if filter: content_list = Content.objects.filter(title__icontains=filter) else: content_list = Content.objects.all() - return render_to_response("ldt/ldt_utils/contentslist.html", + return render_to_response("ldt/ldt_utils/partial/contentslist.html", {'contents': content_list}, context_instance=RequestContext(request)) - - def searchForm(request): form = SearchForm() - return render_to_response('ldt/ldt_utils_utils/search_form.html',{'form': form} , context_instance=RequestContext(request)) + return render_to_response('ldt/ldt_utils/search_form.html',{'form': form} , context_instance=RequestContext(request)) def searchIndex(request): @@ -126,7 +156,7 @@ language_code = request.LANGUAGE_CODE[:2] url = settings.WEB_URL + django.core.urlresolvers.reverse("ldt.ldt_utils.views.searchInit", args=[field, query]) - return render_to_response('irisuser/ldt/init_ldt.html', {'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX+'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX+'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX+'swf/ldt/', 'url': url}, context_instance=RequestContext(request)) + return render_to_response('ldt/ldt_utils/init_ldt.html', {'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX+'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX+'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX+'swf/ldt/', 'url': url}, context_instance=RequestContext(request)) def searchInit(request, field, query): @@ -230,11 +260,15 @@ if form.is_valid(): user = request.user Project.create_project(title=form.cleaned_data['title'], user=user, contents=form.cleaned_data['contents']) - return HttpResponseRedirect(reverse("ldt.ldt_utils.views.list_ldt")) + form_status = "saved" + contents=[] + #return HttpResponseRedirect(reverse("ldt.ldt_utils.views.list_ldt")) else: form = LdtAddForm() - contents = Content.objects.all() - return render_to_response('ldt/ldt_utils/create_ldt.html', {'contents': contents, 'form': form,'create_project_action':reverse(create_ldt_view)}, context_instance=RequestContext(request)) + contents = Content.objects.all() + form_status = "none" + + return render_to_response('ldt/ldt_utils/create_ldt.html', {'contents': contents, 'form': form, 'form_status':form_status,'create_project_action':reverse(create_ldt_view)}, context_instance=RequestContext(request)) def created_ldt(request): return render_to_response('ldt/ldt_utils/save_done.html', context_instance=RequestContext(request)) @@ -261,7 +295,8 @@ resp = HttpResponse(mimetype="text/xml") resp['Cache-Control']='no-cache, must-revalidate' resp['Pragma']='no-cache' - doc.write(resp, pretty_print=True) + + resp.write( etree.tostring(doc, pretty_print=True, xml_declaration=True, encoding="utf-8")) return resp def ldtProject(request, id): @@ -278,19 +313,22 @@ project = get_object_or_404(Project,ldt_id=id) - return project_json(request, project) + return project_json(request, project, False) def project_json_externalid(request, id): res_proj = get_list_or_404(Project.objects.order_by('-modification_date'),contents__external_id = id) - return project_json(request, res_proj[0]) + return project_json(request, res_proj[0], False) -def project_json(request, project): - +def project_json(request, project, serialize_contents = True): + + if not ldt_auth.checkAccess(request.user, project): + return HttpResponseForbidden(_("You can not access this project")) + mimetype = request.REQUEST.get("mimetype") if mimetype is None: mimetype = "application/json; charset=utf-8" @@ -315,7 +353,7 @@ escape_bool = {'true': True, 'false': False, "0": False, "1": True}.get(escape_str.lower()) - ps = ProjectSerializer(project) + ps = ProjectSerializer(project, serialize_contents) project_dict = ps.serialize_to_cinelab() json_str = simplejson.dumps(project_dict, ensure_ascii=False, indent=indent) @@ -330,49 +368,96 @@ return resp +def project_annotations_rdf(request, ldt_id): + + project = Project.objects.get(ldt_id=ldt_id); + + if not ldt_auth.checkAccess(request.user, project): + return HttpResponseForbidden(_("You can not access this project")) + + mimetype = request.REQUEST.get("mimetype") + if mimetype is None: + mimetype = "application/rdf+xml; charset=utf-8" + else: + mimetype = mimetype.encode("utf-8") + if "charset" not in mimetype: + mimetype += "; charset=utf-8" + resp = HttpResponse(mimetype=mimetype) + resp['Cache-Control']='no-cache, must-revalidate' + resp['Pragma']='no-cache' + + ps = ProjectSerializer(project, from_content=False, from_display=True) + annotations = project.getAnnotations(first_cutting=True) + + rdf_ns = u"http://www.w3.org/1999/02/22-rdf-syntax-ns#" + dc_ns = u"http://purl.org/dc/elements/1.1/" + rdf = u"{%s}" % rdf_ns + dc = u"{%s}" % dc_ns + nsmap = {u'rdf' : rdf_ns, u'dc':dc_ns} + + rdf_root = etree.Element(rdf+u"RDF", nsmap=nsmap) + + logging.debug("RDF annotations : " + repr(annotations)) + + for annotation in annotations: + uri = u"" + if 'uri' in annotation and annotation['uri']: + uri = unicode(annotation['uri']) + annot_desc = etree.SubElement(rdf_root, rdf+u"Description") + annot_desc.set(rdf+u'about',uri) + if annotation['title']: + etree.SubElement(annot_desc, dc+'title').text = etree.CDATA(unicode(annotation['title'])) + if annotation['desc']: + etree.SubElement(annot_desc, dc+'description').text = etree.CDATA(unicode(annotation['desc'])) + if annotation['tags']: + for tag in annotation['tags']: + etree.SubElement(annot_desc, dc+'subject').text = etree.CDATA(unicode(tag)) + etree.SubElement(annot_desc,dc+'coverage').text = u"start=%s, duration=%s" % (annotation['begin'], annotation['duration']) + + resp.write(u"\n") + resp.write(u"\n") + + resp.write(etree.tostring(rdf_root, xml_declaration=False, encoding="utf-8", pretty_print=True)) + + return resp def save_ldtProject(request): if request.method=="POST": ldt = request.POST['ldt'] id = request.POST['id'] ldtproject=Project.objects.get(ldt_id=id) - - #save xml ldt + + #save xml ldt ldtproject.ldt=ldt - ldtproj = get_attrib(ldtproject) - ldtproj.save() - else: - ldt = '' - - return render_to_response('ldt/ldt_utils/save_done.html', {'ldt': ldt, 'id':id, 'title':title, 'contents': new_contents}, context_instance=RequestContext(request)) - + doc = lxml.etree.fromstring(ldtproject.ldt.encode( "utf-8" )) + result = doc.xpath("/iri/project") + + #set new title + ldtproject.title = result[0].get("title") + + #get new content list + new_contents=[] + result = doc.xpath("/iri/medias/media") + for medianode in result: + id = medianode.get("id") + new_contents.append(id) -def get_attrib(ldtproject): - doc = lxml.etree.fromstring(ldtproject.ldt.encode( "utf-8" )) - result = doc.xpath("/iri/project") - - for pnode in result: - title = pnode.get("title") - break - - #set new title - ldtproject.title=title - - #get new content list - new_contents=[] - result = doc.xpath("/iri/medias/media") - for medianode in result: - id = medianode.get("id") - new_contents.append(id) - #set new content list for c in ldtproject.contents.all(): if not c.iri_id in new_contents: ldtproject.contents.remove(c) + + ldtproject.save() + else: + ldt = '' + new_contents=[] + + return render_to_response('ldt/ldt_utils/save_done.html', {'ldt': ldt, 'id':id, 'title':ldtproject.title, 'contents': new_contents}, context_instance=RequestContext(request)) - return ldtproject + + @@ -437,7 +522,42 @@ return HttpResponseRedirect(reverse('ldt.ldt_utils.views.indexProject', args=[project.ldt_id])) else: form = AddProjectForm() - return render_to_response('ldt/ldt_utils/create_ldt.html', {'form':form, 'contents':contents, 'iri_id':iri_id, 'create_project_action':reverse("ldt.ldt_utils.views.create_project",args=[iri_id])}, context_instance=RequestContext(request)) + return render_to_response('ldt/ldt_utils/create_ldt.html', {'form':form, 'contents':contents, 'create_project_action':reverse("ldt.ldt_utils.views.create_project",args=[iri_id])}, context_instance=RequestContext(request)) + +@login_required +def update_project(request, ldt_id): + + project = get_object_or_404(Project, ldt_id=ldt_id) + contents = project.contents.all() + if request.method == "POST" : + submit_action = request.REQUEST.get("submit_button",False) + if submit_action == "prepare_delete": + errors = [] + if project.state == 2: + errors.append(_("the project %(title)s is published. please unpublish before deleting.")%{'title':project.title}) + message = _("can not delete the project. Please correct the following error") + title = _('title error deleting project') + else: + message = _("please confirm deleting project %(title)s")%{'title':project.title} + title = _("confirm deletion") + return render_to_response('ldt/ldt_utils/error_confirm.html', {'errors':errors, 'message':message, 'title': title}, context_instance=RequestContext(request)) + elif submit_action == "delete": + if project.state != 2: + project.delete() + form_status= 'deleted' + form = AddProjectForm() + else: + form_status= 'saved' + form = AddProjectForm(request.POST) + if form.is_valid(): + project.title=form.cleaned_data['title'] + project.save() + else: + form = AddProjectForm({'title':unicode(project.title)}) + form_status= 'none' + + return render_to_response('ldt/ldt_utils/create_ldt.html', {'form':form, 'form_status':form_status, 'ldt_id': ldt_id, 'contents':contents, 'create_project_action':reverse("ldt.ldt_utils.views.update_project",args=[ldt_id])}, context_instance=RequestContext(request)) + @login_required def copy_project(request, ldt_id): @@ -486,53 +606,71 @@ media = None elif media_input_type == "link": media = content_form.cleaned_data["media_obj"] - elif media_input_type == "url" or media_input_type == "upload" or media_input_type == "create": + created = False + elif media_input_type == "create": + del cleaned_data["media_file"] + if not cleaned_data['videopath']: + cleaned_data['videopath'] = settings.STREAM_URL + media, created = Media.objects.get_or_create(src=cleaned_data['src'], defaults=cleaned_data) + elif media_input_type == "url" or media_input_type == "upload" : # copy file #complet src destination_file = None source_file = None destination_file_path = None - if media_input_type != "create": - try: - if media_input_type == "url": - url = cleaned_data["external_src_url"] - source_file = urllib2.urlopen(url) - source_filename = source_file.info().get('Content-Disposition', None) - if not source_filename: - source_filename = urlparse.urlparse(url).path.rstrip("/").split('/')[-1] - elif media_input_type == "upload": - source_file = request.FILES['media-media_file'] - source_filename = source_file.name - - - destination_filepath = os.path.join(settings.STREAM_PATH, source_filename) - base_source_filename = source_filename - i = 0 - while os.path.exists(destination_filepath): - base_source_filename = source_filename+"(%d)" % (i) - destination_filepath = os.path.join(settings.STREAM_PATH, base_source_filename) - i += 1 - - destination_file = open(destination_filepath, "w") - src_prefix = settings.STREAM_SRC_PREFIX.rstrip("/") - if len(src_prefix) > 0: - cleaned_data["src"] = src_prefix + "/" + base_source_filename - else: - cleaned_data["src"] = base_source_filename + try: + if media_input_type == "url": + url = cleaned_data["external_src_url"] + source_file = urllib2.urlopen(url) + source_filename = source_file.info().get('Content-Disposition', None) + if not source_filename: + source_filename = urlparse.urlparse(url).path.rstrip("/").split('/')[-1] + elif media_input_type == "upload": + source_file = request.FILES['media-media_file'] + source_filename = source_file.name + + source_filename = ldt_utils_path.sanitize_filename(source_filename) + destination_filepath = os.path.join(settings.STREAM_PATH, source_filename) + base_source_filename = source_filename + extension = base_source_filename.split(".")[-1] + if extension == base_source_filename: + extension = "" + base_basename_filename = base_source_filename + else: + base_basename_filename = base_source_filename[:-1 *(len(extension)+1)] + i = 0 + while os.path.exists(destination_filepath): + base_source_filename = "%s.%d.%s" % (base_basename_filename,i,extension) + destination_filepath = os.path.join(settings.STREAM_PATH, base_source_filename) + i += 1 + destination_file = open(destination_filepath, "w") + src_prefix = settings.STREAM_SRC_PREFIX.rstrip("/") + if len(src_prefix) > 0: + cleaned_data["src"] = src_prefix + "/" + base_source_filename + else: + cleaned_data["src"] = base_source_filename + + chunck = source_file.read(2048) + while chunck: + destination_file.write(chunck) chunck = source_file.read(2048) - while chunck: - destination_file.write(chunck) - chunck = source_file.read(2048) - - except Exception as inst: - logging.debug("write_content_base : POST error when processing file:" + str(inst)) - form_status = "error" - finally: - if destination_file: - destination_file.close() - if source_file: - source_file.close() + + except Exception as inst: + logging.debug("write_content_base : POST error when processing file:" + str(inst)) + form_status = "error" + #set error for form + if media_input_type == "url": + errors = media_form._errors.setdefault("external_src_url", ErrorList()) + errors.append(_("Problem when downloading file from url : ")+str(inst)) + elif media_input_type == "upload": + errors = media_form._errors.setdefault("media_file", ErrorList()) + errors.append(_("Problem when uploading file : ") + str(inst)) + finally: + if destination_file: + destination_file.close() + if source_file: + source_file.close() if form_status != "error": #try: @@ -540,10 +678,13 @@ if not cleaned_data['videopath']: cleaned_data['videopath'] = settings.STREAM_URL media, created = Media.objects.get_or_create(src=cleaned_data['src'], defaults=cleaned_data) - if not created: - for attribute in ('external_id', 'external_permalink', 'external_publication_url', 'external_src_url', 'media_creation_date', 'videopath', 'duration', 'description', 'title'): - setattr(media, attribute, cleaned_data.get(attribute)) - media.save() + else: + media = None + + if media and not created: + for attribute in ('external_id', 'external_permalink', 'external_publication_url', 'external_src_url', 'media_creation_date', 'videopath', 'duration', 'description', 'title'): + setattr(media, attribute, cleaned_data.get(attribute)) + media.save() #except Exception as inst: # logging.debug("write_content_base : POST error when saving media:" + str(inst)) # form_status = "error" @@ -586,18 +727,59 @@ return content_form, media_form, form_status - +@login_required def write_content(request, iri_id=None): - logging.debug("write_content : " + str(iri_id) ) - content_form, media_form, form_status = write_content_base(request, iri_id) - + submit_action = request.REQUEST.get("submit_button",False) + + if submit_action == "prepare_delete": + errors, titles = prepare_delete_content(request, iri_id) + if errors and len(errors) > 0: + message = ungettext("There is %(count)d error when deleting content", "There are %(count)d errors when deleting content", len(errors)) % { 'count': len(errors)} + title_msg = _('title error deleting content') + else: + message = _("Confirm delete content %(titles)s") % { 'titles' : ",".join(titles) } + title_msg = _("confirm delete content") + return render_to_response('ldt/ldt_utils/error_confirm.html', {'errors':errors, 'message':message, 'title': title_msg}, context_instance=RequestContext(request)) + elif submit_action == "delete": + delete_content(request, iri_id) + form_status = "deleted" + content_form = ContentForm() + media_form = MediaForm() + else: + content_form, media_form, form_status = write_content_base(request, iri_id) + if iri_id: create_content_action = reverse('ldt.ldt_utils.views.write_content', kwargs={'iri_id':iri_id}) else: create_content_action = reverse('ldt.ldt_utils.views.write_content') - return render_to_response('ldt/ldt_utils/create_content.html', {'content_form': content_form, 'media_form': media_form,'form_status': form_status,'create_content_action': create_content_action}, context_instance=RequestContext(request)) + return render_to_response('ldt/ldt_utils/create_content.html', {'content_form': content_form, 'media_form': media_form,'form_status': form_status,'create_content_action': create_content_action, 'iri_id': iri_id}, context_instance=RequestContext(request)) + +@login_required +def prepare_delete_content(request, iri_id=None): + errors = [] + titles = [] + if not iri_id: + iri_id = request.REQUEST.get("iri_id", None) + + if iri_id: + for content in Content.objects.filter(iri_id=iri_id): + titles.append(unicode(content.title)) + projects = Content.objects.all()[0].project_set.all() + projects_nb = len(projects) + if projects_nb > 0: + project_titles = [lambda p: p.title for p in projects] + errors.append(ungettext("Content '%(title)s' is referenced by this project : %(project_titles)s. Please delete it beforehand.", "Content '%(title)s' is referenced by %(count)d projects: %(project_titles)s. Please delete them beforehand.", projects_nb)%{'title':content.title,'count':projects_nb, 'project_titles': ",".join(project_titles)}) + + return errors, titles +@login_required +def delete_content(request, iri_id=None): + if not iri_id: + iri_id = request.REQUEST.get("iri_id", None) + + if iri_id: + Content.objects.filter(iri_id=iri_id).delete() diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/locale/en/LC_MESSAGES/django.mo Binary file web/ldt/locale/en/LC_MESSAGES/django.mo has changed diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/locale/en/LC_MESSAGES/django.po --- a/web/ldt/locale/en/LC_MESSAGES/django.po Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/locale/en/LC_MESSAGES/django.po Fri Oct 15 12:36:43 2010 +0200 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-09-21 05:10+0200\n" +"POT-Creation-Date: 2010-10-12 03:19+0200\n" "PO-Revision-Date: 2010-02-17 03:53+0100\n" "Last-Translator: Yves-Marie Haussonne \n" "Language-Team: LANGUAGE \n" @@ -18,15 +18,15 @@ #: forms/widgets.py:17 msgid "Date" -msgstr "" +msgstr "Date" #: forms/widgets.py:17 msgid "Time" -msgstr "" +msgstr "Time" -#: ldt_utils/forms.py:43 ldt_utils/models.py:59 +#: ldt_utils/forms.py:43 ldt_utils/models.py:80 msgid "content.content_creation_date" -msgstr "" +msgstr "content creation date" #: ldt_utils/forms.py:44 msgid "content.media_input_type" @@ -34,66 +34,67 @@ #: ldt_utils/forms.py:44 msgid "file_upload" -msgstr "" +msgstr "file upload" #: ldt_utils/forms.py:44 msgid "url" -msgstr "" +msgstr "url" #: ldt_utils/forms.py:44 msgid "existing_media" -msgstr "" +msgstr "existing media" #: ldt_utils/forms.py:44 -#, fuzzy msgid "create_media" -msgstr "created by" +msgstr "create media" #: ldt_utils/forms.py:44 msgid "none_media" -msgstr "" +msgstr "no media" #: ldt_utils/models.py:23 msgid "media.external_id" -msgstr "" +msgstr "external id" #: ldt_utils/models.py:24 -msgid "content.external_permalink" -msgstr "" +msgid "media.external_permalink" +msgstr "media permalink" -#: ldt_utils/models.py:25 ldt_utils/models.py:26 -msgid "content.external_publication_url" -msgstr "" +#: ldt_utils/models.py:25 +msgid "media.external_publication_url" +msgstr "media publication url" + +#: ldt_utils/models.py:26 +msgid "media.external_src_url" +msgstr "media external source url" #: ldt_utils/models.py:27 msgid "media.creation_date" -msgstr "" +msgstr "media object creation date" #: ldt_utils/models.py:28 msgid "media.media_creation_date" -msgstr "" +msgstr "media creation date" #: ldt_utils/models.py:29 msgid "media.update_date" -msgstr "" +msgstr "update date" #: ldt_utils/models.py:30 msgid "media.videopath" -msgstr "" +msgstr "videopath" #: ldt_utils/models.py:31 -#, fuzzy msgid "media.duration" -msgstr "duration" +msgstr "duration (ms)" #: ldt_utils/models.py:32 msgid "media.creator" -msgstr "" +msgstr "media creator" #: ldt_utils/models.py:33 -#, fuzzy msgid "description" -msgstr "Login" +msgstr "description" #: ldt_utils/models.py:34 #: ldt_utils/templates/ldt/ldt_utils/content_list.html:69 @@ -103,48 +104,117 @@ #: ldt_utils/models.py:35 msgid "media.src" -msgstr "" +msgstr "media source" -#: ldt_utils/models.py:48 +#: ldt_utils/models.py:72 msgid "content.iri_id" -msgstr "" +msgstr "iri id" -#: ldt_utils/models.py:49 +#: ldt_utils/models.py:73 msgid "content.iriurl" -msgstr "" +msgstr "iri url" -#: ldt_utils/models.py:52 +#: ldt_utils/models.py:74 msgid "content.creation_date" -msgstr "" +msgstr "content creation date" -#: ldt_utils/models.py:53 +#: ldt_utils/models.py:75 msgid "content.update_date" -msgstr "" +msgstr "content update date" -#: ldt_utils/models.py:54 +#: ldt_utils/models.py:76 msgid "content.title" -msgstr "" +msgstr "title" -#: ldt_utils/models.py:55 +#: ldt_utils/models.py:77 msgid "content.description" msgstr "description" -#: ldt_utils/models.py:57 +#: ldt_utils/models.py:78 msgid "content.authors" msgstr "authors" -#: ldt_utils/models.py:58 +#: ldt_utils/models.py:79 msgid "content.duration" -msgstr "duration" +msgstr "duration (ms)" -#: ldt_utils/models.py:209 +#: ldt_utils/models.py:248 msgid "created by" msgstr "created by" -#: ldt_utils/models.py:210 +#: ldt_utils/models.py:249 msgid "changed by" msgstr "changed by" +#: ldt_utils/views.py:231 +msgid "You can not access this project" +msgstr "You can not access this project" + +#: ldt_utils/views.py:380 +#, python-format +msgid "the project %(title)s is published. please unpublish before deleting." +msgstr "the project %(title)s is published. please unpublish before deleting." + +#: ldt_utils/views.py:381 +msgid "can not delete the project. Please correct the following error" +msgstr "can not delete the project. Please correct the following error" + +#: ldt_utils/views.py:382 +msgid "title error deleting project" +msgstr "Error when deleting project" + +#: ldt_utils/views.py:384 +#, python-format +msgid "please confirm deleting project %(title)s" +msgstr "Please confirm deleting project %(title)s" + +#: ldt_utils/views.py:385 +msgid "confirm deletion" +msgstr "Confirm deletion" + +#: ldt_utils/views.py:509 +msgid "Problem when downloading file from url : " +msgstr "Problem when downloading file from url: " + +#: ldt_utils/views.py:512 +msgid "Problem when uploading file : " +msgstr "Problem when uploading file: " + +#: ldt_utils/views.py:582 +#, python-format +msgid "There is %(count)d error when deleting content" +msgid_plural "There are %(count)d errors when deleting content" +msgstr[0] "There is %(count)d error when deleting content" +msgstr[1] "There are %(count)d errors when deleting content" + +#: ldt_utils/views.py:583 +msgid "title error deleting content" +msgstr "Error when deleting content" + +#: ldt_utils/views.py:585 +#, python-format +msgid "Confirm delete content %(titles)s" +msgstr "Confirm delete content %(titles)s" + +#: ldt_utils/views.py:586 +msgid "confirm delete content" +msgstr "Confirm delete content" + +#: ldt_utils/views.py:618 +#, python-format +msgid "" +"Content '%(title)s' is referenced by this project : %(project_titles)s. " +"Please delete it beforehand." +msgid_plural "" +"Content '%(title)s' is referenced by %(count)d projects: %(project_titles)s. " +"Please delete them beforehand." +msgstr[0] "" +"Content '%(title)s' is referenced by this project : %(project_titles)s. " +"Please delete it beforehand." +msgstr[1] "" +"Content '%(title)s' is referenced by %(count)d projects: %(project_titles)s. " +"Please delete them beforehand." + #: ldt_utils/templates/admin/ldt_utils/app_action.html:4 #: templates/admin/cms_change_list.html:7 #: templates/admin/page_app_index.html:8 @@ -214,6 +284,14 @@ msgid "Create" msgstr "Create" +#: ldt_utils/templates/ldt/ldt_utils/error_confirm.html:16 +msgid "error" +msgstr "Error" + +#: ldt_utils/templates/ldt/ldt_utils/error_confirm.html:25 +msgid "close_error" +msgstr "Close" + #: ldt_utils/templates/ldt/ldt_utils/ldt_list.html:59 msgid "Create new project" msgstr "Create new project" diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/locale/fr/LC_MESSAGES/django.mo Binary file web/ldt/locale/fr/LC_MESSAGES/django.mo has changed diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/locale/fr/LC_MESSAGES/django.po --- a/web/ldt/locale/fr/LC_MESSAGES/django.po Thu Oct 14 12:17:31 2010 +0200 +++ b/web/ldt/locale/fr/LC_MESSAGES/django.po Fri Oct 15 12:36:43 2010 +0200 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-09-21 05:10+0200\n" +"POT-Creation-Date: 2010-10-12 03:19+0200\n" "PO-Revision-Date: 2010-03-09 15:52+0100\n" "Last-Translator: Yves-Marie Haussonne \n" "Language-Team: LANGUAGE \n" @@ -24,7 +24,7 @@ msgid "Time" msgstr "Time" -#: ldt_utils/forms.py:43 ldt_utils/models.py:59 +#: ldt_utils/forms.py:43 ldt_utils/models.py:80 msgid "content.content_creation_date" msgstr "Date de creation du contenu" @@ -46,7 +46,7 @@ #: ldt_utils/forms.py:44 msgid "create_media" -msgstr "créé par" +msgstr "source serveur de stream" #: ldt_utils/forms.py:44 msgid "none_media" @@ -57,13 +57,17 @@ msgstr "id externe" #: ldt_utils/models.py:24 -msgid "content.external_permalink" +msgid "media.external_permalink" msgstr "permalien externe" -#: ldt_utils/models.py:25 ldt_utils/models.py:26 -msgid "content.external_publication_url" +#: ldt_utils/models.py:25 +msgid "media.external_publication_url" msgstr "url de publication externe" +#: ldt_utils/models.py:26 +msgid "media.external_src_url" +msgstr "url source" + #: ldt_utils/models.py:27 msgid "media.creation_date" msgstr "Date de création" @@ -82,7 +86,7 @@ #: ldt_utils/models.py:31 msgid "media.duration" -msgstr "Durée du contenu" +msgstr "Durée du contenu (ms)" #: ldt_utils/models.py:32 msgid "media.creator" @@ -102,46 +106,116 @@ msgid "media.src" msgstr "Sources" -#: ldt_utils/models.py:48 +#: ldt_utils/models.py:72 msgid "content.iri_id" msgstr "iri id" -#: ldt_utils/models.py:49 +#: ldt_utils/models.py:73 msgid "content.iriurl" msgstr "iri url" -#: ldt_utils/models.py:52 +#: ldt_utils/models.py:74 msgid "content.creation_date" msgstr "date de création" -#: ldt_utils/models.py:53 +#: ldt_utils/models.py:75 msgid "content.update_date" msgstr "Date de maj" -#: ldt_utils/models.py:54 +#: ldt_utils/models.py:76 msgid "content.title" msgstr "titre" -#: ldt_utils/models.py:55 +#: ldt_utils/models.py:77 msgid "content.description" msgstr "Description" -#: ldt_utils/models.py:57 +#: ldt_utils/models.py:78 msgid "content.authors" msgstr "Autheurs" -#: ldt_utils/models.py:58 +#: ldt_utils/models.py:79 msgid "content.duration" -msgstr "Durée" +msgstr "Durée (ms)" -#: ldt_utils/models.py:209 +#: ldt_utils/models.py:248 msgid "created by" msgstr "créé par" -#: ldt_utils/models.py:210 +#: ldt_utils/models.py:249 msgid "changed by" msgstr "modifié par" +#: ldt_utils/views.py:231 +msgid "You can not access this project" +msgstr "vous n'avez pas l'autorisation d'accéder à ce projet" + +#: ldt_utils/views.py:380 +#, python-format +msgid "the project %(title)s is published. please unpublish before deleting." +msgstr "Le projet %(title)s est publié. Déplublier le avant de l'effacer." + +#: ldt_utils/views.py:381 +msgid "can not delete the project. Please correct the following error" +msgstr "" +"Le projet ne peut pas être effacé. Veuillez corriger les erreurs suivantes." + +#: ldt_utils/views.py:382 +msgid "title error deleting project" +msgstr "Erreur lors de l'effacement du projet" + +#: ldt_utils/views.py:384 +#, python-format +msgid "please confirm deleting project %(title)s" +msgstr "Confirmer l'efaccement du projet intitulé %(title)s" + +#: ldt_utils/views.py:385 +msgid "confirm deletion" +msgstr "Confirmation d'effacement" + +#: ldt_utils/views.py:509 +msgid "Problem when downloading file from url : " +msgstr "Problème lors du téléchargement du fichier : " + +#: ldt_utils/views.py:512 +msgid "Problem when uploading file : " +msgstr "Problème lors de l'upload du fichier : " + +#: ldt_utils/views.py:582 +#, python-format +msgid "There is %(count)d error when deleting content" +msgid_plural "There are %(count)d errors when deleting content" +msgstr[0] "Il y a %(count)d erreur lors de l'effacement du contenu" +msgstr[1] "Il y a %(count)d erreurs lors de l'effacement du contenu" + +#: ldt_utils/views.py:583 +msgid "title error deleting content" +msgstr "Erreur lors de l'effacement du contenu" + +#: ldt_utils/views.py:585 +#, python-format +msgid "Confirm delete content %(titles)s" +msgstr "Veuillez confirmer l'effacement du contenu %(titles)s" + +#: ldt_utils/views.py:586 +msgid "confirm delete content" +msgstr "Confirmation effacement contenu" + +#: ldt_utils/views.py:618 +#, python-format +msgid "" +"Content '%(title)s' is referenced by this project : %(project_titles)s. " +"Please delete it beforehand." +msgid_plural "" +"Content '%(title)s' is referenced by %(count)d projects: %(project_titles)s. " +"Please delete them beforehand." +msgstr[0] "" +"Le contenu '%(title)s' est référencé par le projet '%(project_titles)s'." +"Veuillez l'effacer préalablement." +msgstr[1] "" +"Le contenu '%(title)s' est référencé par les projets suivants : " +"'%(project_titles)s'.Veuillez les effacer préalablement." + #: ldt_utils/templates/admin/ldt_utils/app_action.html:4 #: templates/admin/cms_change_list.html:7 #: templates/admin/page_app_index.html:8 @@ -170,7 +244,6 @@ msgstr "Liste des contenus" #: ldt_utils/templates/ldt/ldt_utils/content_list.html:63 -#, fuzzy msgid "Create new content" msgstr "Créer un nouveau contenu" @@ -180,7 +253,6 @@ #: ldt_utils/templates/ldt/ldt_utils/content_list.html:70 #: ldt_utils/templates/ldt/ldt_utils/content_list.html:77 -#, fuzzy msgid "create project" msgstr "Créer un nouveau projet Ligne de Temps" @@ -213,6 +285,14 @@ msgid "Create" msgstr "Créer" +#: ldt_utils/templates/ldt/ldt_utils/error_confirm.html:16 +msgid "error" +msgstr "Erreur" + +#: ldt_utils/templates/ldt/ldt_utils/error_confirm.html:25 +msgid "close_error" +msgstr "Fermer" + #: ldt_utils/templates/ldt/ldt_utils/ldt_list.html:59 msgid "Create new project" msgstr "Créer un nouveau projet Ligne de Temps" diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/templates/ldt/ldt_base.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/templates/ldt/ldt_base.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,87 @@ +{% extends "ldt/ldt_raw_base.html" %} +{% load i18n %} +{% load logintag %} +{% load navigation %} + +{% block js_import %} + {{ block.super }} + + + +{% endblock %} + +{% block css_import %} + {{ block.super }} + + + +{% endblock %} + +{% block body %} + {{ block.super }} +
+ + + +
+ +
+ {% block toolbar %} +
+
+ {% if user.is_authenticated %} + {% url ldt.ldt_utils.views.workspace as workspace_url %} + {% url ldt.ldt_utils.views.list_ldt as space_url %} + {% url ldt.ldt_utils.views.list_content as content_url %} + {% url ldt.user.views.profile as profile_url %} + + {% endif %} +
+
+ {% if user.is_authenticated %} + {{user.username}} | {% trans "Log out" %} + {% endif %} +
+
+ {% if LANGUAGES.1 %} +
+ + + + + +
+ {% endif %} + {% endblock %} +
+
+ {% block content %}{% endblock %} +
+
+ +
+{% endblock %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/templates/ldt/ldt_raw_base.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/templates/ldt/ldt_raw_base.html Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,45 @@ +{% load i18n %} +{% load logintag %} +{% load navigation %} + + + + +{% block head %} + + + + {% block title %}France Culture{% endblock %} + {% block js_import %} + + {% endblock %} + + {% block css_declaration %} + + {% endblock %} + + {% block css_import %} + + + + + + + {% endblock %} + + {% block js_declaration %} + {% endblock %} +{% endblock %} + + +{% block body %} +{% endblock %} + + diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/templates/ldt_base.html --- a/web/ldt/templates/ldt_base.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -{% extends "ldt_raw_base.html" %} -{% load i18n %} -{% load logintag %} -{% load navigation %} - -{% block js_import %} - {{ block.super }} - - - -{% endblock %} - -{% block css_import %} - {{ block.super }} - - - -{% endblock %} - -{% block body %} - {{ block.super }} -
- - - -
- -
- {% block toolbar %} -
-
- {% if user.is_authenticated %} - {% url ldt.ldt_utils.views.workspace as workspace_url %} - {% url ldt.ldt_utils.views.list_ldt as space_url %} - {% url ldt.ldt_utils.views.list_content as content_url %} - {% url ldt.user.views.profile as profile_url %} - - {% endif %} -
-
- {% if user.is_authenticated %} - {{user.username}} | {% trans "Log out" %} - {% endif %} -
-
- {% if LANGUAGES.1 %} -
-
- - - -
-
- {% endif %} - {% endblock %} -
-
- {% block content %}{% endblock %} -
-
- -
-{% endblock %} diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/templates/ldt_raw_base.html --- a/web/ldt/templates/ldt_raw_base.html Thu Oct 14 12:17:31 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -{% load i18n %} -{% load logintag %} -{% load navigation %} - - - - -{% block head %} - - - - {% block title %}France Culture{% endblock %} - {% block js_import %} - - {% endblock %} - - {% block css_declaration %} - - {% endblock %} - - {% block css_import %} - - - - - - - {% endblock %} - - {% block js_declaration %} - {% endblock %} -{% endblock %} - - -{% block body %} -{% endblock %} - - diff -r 2f978b081c4c -r 9927a619d2b5 web/ldt/utils/path.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/utils/path.py Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,14 @@ +""" +Some small file related utilities +""" + +import unicodedata +import string + +validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits) + + +def sanitize_filename(filename): + cleanedFilename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore').lower() + return ''.join(c for c in cleanedFilename if c in validFilenameChars).replace(' ','_') + \ No newline at end of file diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/css/embed_popup.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/static/ldt/css/embed_popup.css Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,33 @@ +pre { +white-space: pre-wrap; /* css-3 */ +white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ +white-space: -pre-wrap; /* Opera 4-6 */ +white-space: -o-pre-wrap; /* Opera 7 */ +word-wrap: break-word; /* Internet Explorer 5.5+ */ +} + +input +{ + background: #ededed; +} + +input[type="button"] { + background-color: #656565; + color: white; + width: auto; + font-weight: bold; + padding: 5px 10px; +} + +#button_row input { + margin: 10px; +} + +#display_select { + float: left; +} + +#copy_div { + float: right; +} + diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/css/ldtform.css --- a/web/static/ldt/css/ldtform.css Thu Oct 14 12:17:31 2010 +0200 +++ b/web/static/ldt/css/ldtform.css Fri Oct 15 12:36:43 2010 +0200 @@ -47,10 +47,27 @@ #submitcontent { border-top: 1px solid black; padding-top : 10px; +} + +#submitcontent-buttons { text-align: right; } -#add_content input[type="submit"], #add_contribution input[type="submit"] { +#submitcontent-loader { + text-align: left; +} + +.submitcontent-loader-content { + display: none; +} + + +#submitcontent-loader-msg { + padding-left: 6px; +} + + +#submitcontent-buttons input[type="submit"], #submitcontent-buttons button { background-color: #656565; color: white; width:auto; @@ -114,3 +131,9 @@ border: 1px solid #DDD; } +.error_message { + padding: 3em 2em; + font-size: larger; + font-weight: bold; +} + diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/css/workspace.css --- a/web/static/ldt/css/workspace.css Thu Oct 14 12:17:31 2010 +0200 +++ b/web/static/ldt/css/workspace.css Fri Oct 15 12:36:43 2010 +0200 @@ -109,6 +109,12 @@ color: #4F5155; } +.projecttitlelink,.projecttitlelink:link,.projecttitlelink:hover,.projecttitlelink:visited { + text-decoration: none; + color: #4F5155; +} + + .projecttitle { width: 367px; padding: 4px 10px 4px 5px; diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/img/ajax-loader-220x19.gif Binary file web/static/ldt/img/ajax-loader-220x19.gif has changed diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/js/embed_popup.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/static/ldt/js/embed_popup.js Fri Oct 15 12:36:43 2010 +0200 @@ -0,0 +1,49 @@ +var display_state = "player"; + +function toggle_display() { + $j.each(["player","seo_body","seo_meta","links"], function(i,display_str) { + + var div_selector = "#"+display_str+"_code"; + if(display_str == display_state) { + $j(div_selector).show(); + } + else { + $j(div_selector).hide(); + } + }); +} + +$j(document).ready(function(){ + + toggle_display(); + + $j('.ldt_json_link').click(function(e) { + e.preventDefault(); + link = $j(e.target); + $j("#res_link_{{player_id}}").load(link.attr("href")); + $j("#res_link_{{player_id}}").show(); + return false; + }); + + $j('#player_button').click(function(e) { + display_state = "player"; + toggle_display(); + }); + $j('#seo_body_button').click(function(e) { + display_state = "seo_body"; + toggle_display(); + }); + $j('#seo_meta_button').click(function(e) { + display_state = "seo_meta"; + toggle_display(); + }); + $j('#links_button').click(function(e) { + display_state = "links"; + toggle_display(); + }); + + $j("#copy_button").click(function(e) { + alert($j("#"+display_state+"_code").html()); + }); + +}); diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/js/projectscontents.js --- a/web/static/ldt/js/projectscontents.js Thu Oct 14 12:17:31 2010 +0200 +++ b/web/static/ldt/js/projectscontents.js Fri Oct 15 12:36:43 2010 +0200 @@ -23,51 +23,31 @@ width:1022, bgColor: 'rgb(239, 239, 239)', padding: 5, - titleFromIframe: false + titleFromIframe: false, + beforeHideContent: function(elts, settings, callback){ + try { + var res = $('#ldtInitSwf',$('#nyroModalIframe').contents()); + if(res.length > 0) + { + res.get(0).forceSave(); + } + } + catch(err) + { + // do nothing + } + callback(); + }, + }); - $('.ldt_link_create',base_node).nyroModal({ - type: 'iframe', - forceType: 'iframe', - windowResize: false, - height:680, - width:500, - bgColor: 'rgb(239, 239, 239)', - padding: 5, - titleFromIframe: false, - beforeHideContent: function(elts, settings, callback){ - try { - var res = $('#ldtInitSwf',$('#nyroModalIframe').contents()); - if(res.length > 0) - { - res.get(0).forceSave(); - } - } - catch(err) - { - // do nothing - } - callback(); - }, - endShowContent: function(elts, settings){ - var iframe = $('#nyroModalIframe', elts.content); - iframe.load(function(){ - var swfobject = $(this).contents().find("#ldtInitSwf"); - if (swfobject.length) { - $.nyroModalSettings({ - height: swfobject.height() + 31, - width: swfobject.width() + 21 - }); - } - }); - } - }); $('.ldt_link_embed',base_node).click(function(e) { e.preventDefault(); var link = $(e.target); var json_url = link.attr("href"); var player_id = link.attr("id"); + var ldt_id = player_id.substring(15); /*$.nyroModalSettings({ ajax: { data: ({ json_url:json_url, player_id:player_id }) } });*/ @@ -79,7 +59,7 @@ width:750, bgColor: 'rgb(239, 239, 239)', padding: 5, - url: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id), + url: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id)+'&ldt_id='+escape(ldt_id), }); return false; }); @@ -129,25 +109,30 @@ if(target.attr('timer')) { clearTimeout(target.attr('timer')); } - - target.attr('timer',setTimeout(function() { - target.next(".searchajaxloader").show(); - target.nextAll(".searchclear").hide(); - var realVal = target.realVal(); - if(realVal.length == 0) { - realVal = "_"; - } - url = url.replace('__FILTER__',escape(realVal)); - $(container_selector).load(url, null, function() { - target.next(".searchajaxloader").hide(); - if(target.realVal().length > 0) { - target.nextAll(".searchclear").show(); - } - init_events($(container_selector)); - target.removeAttr('timer'); - }); - }, - 300)); + + target.attr( + 'timer', + setTimeout(function() { + target.next(".searchajaxloader").show(); + target.nextAll(".searchclear").hide(); + var filterVal = "_" + escape(target.realVal()); + url = url.replace('__FILTER__',filterVal); + $.ajax({ + url: url, + cache: false, + success: function(data, status, request) { + $(container_selector).html(data); + target.next(".searchajaxloader").hide(); + if(target.realVal().length > 0) { + target.nextAll(".searchclear").show(); + } + init_events($(container_selector)); + target.removeAttr('timer'); + } + }); + }, + 300) + ); }; @@ -169,7 +154,7 @@ endShowContent: function(elts, settings) { $('#nyroModalIframe', elts.content).load(function() { var form_status = $(this).contents().find("#content_form_status").val(); - if(form_status == 'saved') { + if(form_status == 'saved' || form_status == 'deleted' ) { $.nyroModalRemove(); } }); @@ -185,12 +170,12 @@ padding: 5, titleFromIframe: false, endRemove: function(elts, settings) { - searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url) + searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url,0); }, endShowContent: function(elts, settings) { $('#nyroModalIframe', elts.content).load(function() { var form_status = $(this).contents().find("#content_form_status").val(); - if(form_status == 'saved') { + if(form_status == 'saved' || form_status == 'deleted') { $.nyroModalRemove(); } }); @@ -201,7 +186,52 @@ } function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { - + + $('.ldt_link_create',base_node).nyroModal({ + type: 'iframe', + forceType: 'iframe', + windowResize: false, + height:680, + width:500, + bgColor: 'rgb(239, 239, 239)', + padding: 5, + titleFromIframe: false, + endRemove: function(elts, settings) { + searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); + }, + beforeHideContent: function(elts, settings, callback){ + try { + var res = $('#ldtInitSwf',$('#nyroModalIframe').contents()); + if(res.length > 0) + { + res.get(0).forceSave(); + } + } + catch(err) + { + // do nothing + } + callback(); + }, + endShowContent: function(elts, settings){ + var iframe = $('#nyroModalIframe', elts.content); + iframe.load(function(){ + var form_status = $(this).contents().find("#project_form_status").val(); + if(form_status == 'saved' || form_status == 'deleted' ) { + $.nyroModalRemove(); + } + var swfobject = $(this).contents().find("#ldtInitSwf"); + if (swfobject.length) { + $.nyroModalSettings({ + height: swfobject.height() + 31, + width: swfobject.width() + 21 + }); + } + }); + } + }); + + $('.publishedproject', base_node).click(function(e) { e.preventDefault(); var target = $(e.target); @@ -236,6 +266,27 @@ }); }); + $('.projecttitlelink').nyroModal({ + type: 'iframe', + forceType: 'iframe', + height:680, + width:500, + bgColor: 'rgb(239, 239, 239)', + padding: 5, + titleFromIframe: false, + endRemove: function(elts, settings) { + searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); + }, + endShowContent: function(elts, settings) { + $('#nyroModalIframe', elts.content).load(function() { + var form_status = $(this).contents().find("#project_form_status").val(); + if(form_status == 'saved' || form_status == 'deleted') { + $.nyroModalRemove(); + } + }); + } + }); + } function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { diff -r 2f978b081c4c -r 9927a619d2b5 web/static/ldt/swf/ldt/LignesDeTempsFlex.swf Binary file web/static/ldt/swf/ldt/LignesDeTempsFlex.swf has changed