# HG changeset patch # User hamidouk # Date 1328260952 -3600 # Node ID c39f905103d3c897dd06724d7a4c5d2391e7693d # Parent 5e8b72d30bd80c90fcaf5bddd51865309b1b3d33# Parent 2ae1a476a69d924b665e5f68378adab05494b8da Merge with upstream diff -r 5e8b72d30bd8 -r c39f905103d3 src/ldt/ldt/ldt_utils/models.py --- a/src/ldt/ldt/ldt_utils/models.py Fri Feb 03 10:22:11 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/models.py Fri Feb 03 10:22:32 2012 +0100 @@ -224,7 +224,10 @@ create_front_project = True if not self.nb_annotation: - self.nb_annotation = 0 + self.nb_annotation = 0 + if not self.stat_annotation: + self.stat_annotation = self.__list2str([0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + len(settings.SYNTAX.keys()))) + super(Content, self).save(*args, **kwargs) @@ -373,10 +376,10 @@ set_current_user(admin) self.front_project = Project.create_project(admin, 'front project : %s' % self.title, [self], cuttings=['chapitrage', 'contributions'] ) - self.front_project.publish(allow_write=True) + self.front_project.publish(allow_write=True) + self.save() set_current_user(old_user) - - self.save() + # Tag management def get_tags(self): diff -r 5e8b72d30bd8 -r c39f905103d3 src/ldt/ldt/ldt_utils/views/content.py --- a/src/ldt/ldt/ldt_utils/views/content.py Fri Feb 03 10:22:11 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/views/content.py Fri Feb 03 10:22:32 2012 +0100 @@ -215,15 +215,14 @@ cached_assign('change_content', request.user, content) cached_assign('view_content', request.user, content) everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME) - print content_form.cleaned_data if content_form.cleaned_data['is_public']: cached_assign('view_content', everyone, content) if media: cached_assign('view_media', everyone, media) else: - remove_perm('view_content', everyone, content) - remove_perm('view_media', everyone, media) + remove_perm('ldt_utils.view_content', everyone, content) + remove_perm('ldt_utils.view_media', everyone, media) assign_perm_to_obj(content, content_form.cleaned_data['read_list'], content_form.cleaned_data['write_list'], request.user) if media: assign_perm_to_obj(media, content_form.cleaned_data['read_list'], content_form.cleaned_data['write_list'], request.user) diff -r 5e8b72d30bd8 -r c39f905103d3 src/ldt/ldt/ldt_utils/views/front.py --- a/src/ldt/ldt/ldt_utils/views/front.py Fri Feb 03 10:22:11 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/views/front.py Fri Feb 03 10:22:32 2012 +0100 @@ -12,7 +12,7 @@ def front_home(request): # Get the 3 last annotated contents - last_contents = Content.objects.order_by('-last_annotated')[:3] + last_contents = Content.objects.order_by('-last_annotated').exclude(nb_annotation=0)[:3] # Get the most annotated contents most_contents = Content.objects.order_by('-nb_annotation')[:8] # Get the active groups @@ -91,18 +91,13 @@ proj = proj[0] else: proj = Project.safe_objects.get(ldt_id=project_id) - - if not proj.state == 2: # If the original front project is unpublished - content.create_front_project() - proj = content.front_project - - + # Vars for player player_id = "player_project_" + proj.ldt_id if cutting_id is None : json_url = reverse("ldt.ldt_utils.views.json.project_json_id", args=[proj.ldt_id]) - else : + else: json_url = reverse("ldt.ldt_utils.views.json.project_json_cutting_id", args=[proj.ldt_id, cutting_id]) player_width = 550 player_height = 380 diff -r 5e8b72d30bd8 -r c39f905103d3 src/ldt/ldt/security/__init__.py --- a/src/ldt/ldt/security/__init__.py Fri Feb 03 10:22:11 2012 +0100 +++ b/src/ldt/ldt/security/__init__.py Fri Feb 03 10:22:32 2012 +0100 @@ -90,8 +90,12 @@ def wrapper(func): def wrapped(self, *args, **kwargs): - if self.pk and not get_current_user().has_perm('change_%s' % cls_name, self): - raise AttributeError('User %s is not allowed to change object %s' % (get_current_user(), self)) + user = get_current_user() + if not user: + user = get_anonymous_user() + + if self.pk and not user.has_perm('change_%s' % cls_name, self): + raise AttributeError('User %s is not allowed to change object %s' % (user, self)) return func(self, *args, **kwargs) return wrapped diff -r 5e8b72d30bd8 -r c39f905103d3 src/ldt/ldt/security/command.py --- a/src/ldt/ldt/security/command.py Fri Feb 03 10:22:11 2012 +0100 +++ b/src/ldt/ldt/security/command.py Fri Feb 03 10:22:32 2012 +0100 @@ -28,8 +28,12 @@ total = list_model['Project'].objects.count() for proj in list_model['Project'].objects.all(): - assign('ldt_utils.change_project', proj.owner, proj) - assign('ldt_utils.view_project', proj.owner, proj) + + if proj.state == 2: + proj.publish() + else: + proj.unpublish() + if verbose: show_progress(i, total, "Assign permissions to projects", 40, writer) i += 1 diff -r 5e8b72d30bd8 -r c39f905103d3 src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js --- a/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Fri Feb 03 10:22:11 2012 +0100 +++ b/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Fri Feb 03 10:22:32 2012 +0100 @@ -71,7 +71,7 @@ .split(";") .map(function(t) { return t.replace(/(^[\s]+|[\s]+$)/g,"") }) .filter(function(t) { return t.length; }) - .map(function(t) { return '' + t + ''; }) + .map(function(t) { return '' + t + ''; }) .join(', ') ) }).mouseout(function() {