--- a/src/ldt/ldt/ldt_utils/admin.py Mon Jan 16 14:23:04 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/admin.py Mon Jan 16 15:33:27 2012 +0100
@@ -5,13 +5,17 @@
from ldt.ldt_utils.contentindexer import ContentIndexer, ProjectIndexer
from ldt.ldt_utils.fileimport import FileImport, FileImportError
from ldt.ldt_utils.forms import LdtImportForm, ReindexForm, StatAnnotationForm
-from ldt.ldt_utils.models import Content, Project, Media, Author
-#from ldt.ldt_utils.stat import compute_stats_for
+from ldt.ldt_utils.models import Content, Project, Media, Author, AnnotationStat
import ldt.indexation
from guardian.admin import GuardedModelAdmin
+
+class StatInlineAdmin(admin.TabularInline):
+ model = AnnotationStat
+ extra = 1
+
class ProjectAdmin(GuardedModelAdmin):
- pass
+ inlines = [StatInlineAdmin, ]
class AuthorAdmin(GuardedModelAdmin):
pass
--- a/src/ldt/ldt/ldt_utils/models.py Mon Jan 16 14:23:04 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/models.py Mon Jan 16 15:33:27 2012 +0100
@@ -364,7 +364,7 @@
admin = User.objects.filter(is_superuser=True)[0]
set_current_user(admin)
- self.front_project = Project.create_project(admin, 'front_%s' % self.iri_id, [self], cuttings=['chapitrage', 'contribution'] )
+ self.front_project = Project.create_project(admin, 'front project : %s' % self.title, [self], cuttings=['chapitrage', 'contribution'] )
self.front_project.publish(allow_write=True)
set_current_user(request_user)
--- a/src/ldt/ldt/ldt_utils/stat.py Mon Jan 16 14:23:04 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/stat.py Mon Jan 16 15:33:27 2012 +0100
@@ -84,21 +84,23 @@
def delete_stat_project(sender, instance, **kwargs):
- contents = instance.contents.all()
+ contents = list(instance.contents.all())
contributions = AnnotationStat.objects.filter(project=instance)
for c in contributions:
- content = contents.get(id=c.content.id)
-
- if c.nb_annotation:
- content.nb_annotation -= c.nb_annotation
-
- if c.stat:
- content_stat = get_buckets_from_string(content.stat_annotation)
- proj_stat = get_buckets_from_string(c.stat)
- content.stat_annotation = get_string_from_buckets([pair[0] - pair[1] for pair in zip(content_stat, proj_stat)])
-
- content.save()
+ result = [x for x in contents if x.id == c.content.id ]
+ if result:
+ content = result[0]
+
+ if c.nb_annotation:
+ content.nb_annotation -= c.nb_annotation
+
+ if c.stat:
+ content_stat = get_buckets_from_string(content.stat_annotation)
+ proj_stat = get_buckets_from_string(c.stat)
+ content.stat_annotation = get_string_from_buckets([pair[0] - pair[1] for pair in zip(content_stat, proj_stat)])
+
+ content.save()
pre_delete.connect(delete_stat_project, sender=Project)
--- a/src/ldt/ldt/user/admin.py Mon Jan 16 14:23:04 2012 +0100
+++ b/src/ldt/ldt/user/admin.py Mon Jan 16 15:33:27 2012 +0100
@@ -5,10 +5,13 @@
from django.utils.translation import ugettext as _
from forms import LdtForm
from guardian.admin import GuardedModelAdmin
-from models import Ldt, UserProfile
+from models import Ldt, UserProfile, GroupProfile
+
+class GroupProfileInline(admin.StackedInline):
+ model = GroupProfile
class GroupAdmin(GuardedModelAdmin):
- pass
+ inlines = [GroupProfileInline, ]
class UserProfileInline(admin.StackedInline):
model = UserProfile