# HG changeset patch # User verrierj # Date 1328020842 -3600 # Node ID b0da8cecb6b36065121c295a6a1b5be2aa247c4a # Parent 403f92f241441014b85e0ffaa4c71a31d7fed1ae View annot_content always finds a project diff -r 403f92f24144 -r b0da8cecb6b3 src/ldt/ldt/ldt_utils/models.py --- a/src/ldt/ldt/ldt_utils/models.py Tue Jan 31 14:38:21 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/models.py Tue Jan 31 15:40:42 2012 +0100 @@ -6,7 +6,7 @@ from ldt.core.models import Document from guardian.shortcuts import assign, remove_perm, get_perms import ldt.indexation -from ldt.security import get_current_user_or_admin, set_current_user +from ldt.security import get_current_user_or_admin, set_current_user, get_current_user from ldt.security.models import SafeModel from ldt.security.manager import SafeManager from sorl.thumbnail import ImageField @@ -234,6 +234,8 @@ # We need a primary key for self in create_project, so # save() has to be called first self.create_front_project() + assign('ldt_utils.change_content', get_current_user(), self) + def __unicode__(self): return str(self.id) + ": " + self.iri_id @@ -364,19 +366,18 @@ is_public = property(**is_public()) def create_front_project(self): - request_user = get_current_user_or_admin() + old_user = get_current_user_or_admin() - if request_user.is_superuser: - admin = request_user + if old_user.is_superuser: + admin = old_user else: admin = User.objects.filter(is_superuser=True)[0] 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) - set_current_user(request_user) + set_current_user(old_user) - assign('ldt_utils.change_content', request_user, self) self.save() # Tag management diff -r 403f92f24144 -r b0da8cecb6b3 src/ldt/ldt/ldt_utils/views/front.py --- a/src/ldt/ldt/ldt_utils/views/front.py Tue Jan 31 14:38:21 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/views/front.py Tue Jan 31 15:40:42 2012 +0100 @@ -7,7 +7,6 @@ from guardian.shortcuts import get_objects_for_group from ldt.ldt_utils.models import Content, Project from ldt.ldt_utils.views.workspace import search_index as ws_search_index, search_listing as ws_search_listing -from ldt.security.utils import add_change_attr from tagging.models import Tag, TaggedItem @@ -55,9 +54,9 @@ tag_label = request.GET.get("tag") # Get all the public contents group if tag_label is None : - content_list = add_change_attr(request.user, Content.safe_objects.all()) + content_list = Content.safe_objects.all() else : - content_list = TaggedItem.objects.get_by_model(add_change_attr(request.user, Content.safe_objects.all()), '"'+tag_label+'"') + content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all(), '"'+tag_label+'"') # Get the main tag list front_tags = settings.FRONT_TAG_LIST # Get the all tags list @@ -87,7 +86,12 @@ proj = front_proj else: # The main project for the content - proj = Project.safe_objects.filter(contents__in=[content], state=2)[0] + proj = Project.safe_objects.filter(contents__in=[content], state=2) + if not proj: + content.create_front_project() + proj = content.front_project + else: + proj = proj[0] else: proj = Project.safe_objects.get(ldt_id=project_id)