# HG changeset patch # User durandn # Date 1471437502 -7200 # Node ID 088195b2a6cc6bdee5a0bed22cbbe8eac7e8ce50 # Parent 4728f6c0102ea9203ab0236d954cb476bdd8f401 iconolab profile to user relation is now one to one field + added panel for collection admin user tools (to be added) in user home + (simple) django admin for iconolab objects diff -r 4728f6c0102e -r 088195b2a6cc src/iconolab/admin.py --- a/src/iconolab/admin.py Tue Aug 16 17:02:57 2016 +0200 +++ b/src/iconolab/admin.py Wed Aug 17 14:38:22 2016 +0200 @@ -1,1 +1,20 @@ -from django.contrib import admin \ No newline at end of file +from django.contrib import admin +from iconolab import models + +# Iconolab objects +admin.site.register(models.Collection) +admin.site.register(models.Item) +admin.site.register(models.Image) +admin.site.register(models.Annotation) +admin.site.register(models.AnnotationRevision) +# Tags +admin.site.register(models.Tag) +admin.site.register(models.TaggingInfo) + +# User +admin.site.register(models.UserProfile) + +# Comment system +admin.site.register(models.IconolabComment) +admin.site.register(models.MetaCategory) +admin.site.register(models.MetaCategoryInfo) \ No newline at end of file diff -r 4728f6c0102e -r 088195b2a6cc src/iconolab/migrations/0012_auto_20160817_1019.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/migrations/0012_auto_20160817_1019.py Wed Aug 17 14:38:22 2016 +0200 @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-17 10:19 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('iconolab', '0011_userprofile'), + ] + + operations = [ + migrations.AlterField( + model_name='userprofile', + name='user', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL), + ), + ] diff -r 4728f6c0102e -r 088195b2a6cc src/iconolab/models.py --- a/src/iconolab/models.py Tue Aug 16 17:02:57 2016 +0200 +++ b/src/iconolab/models.py Wed Aug 17 14:38:22 2016 +0200 @@ -19,12 +19,17 @@ def is_internal(self): return self.link.startswith(settings.INTERNAL_TAGS_URL) + def __str__(self): + return self.label_slug+":"+self.label class TaggingInfo(models.Model): revision = models.ForeignKey('AnnotationRevision', on_delete=models.CASCADE) tag = models.ForeignKey('Tag', on_delete=models.CASCADE) accuracy = models.IntegerField() relevancy = models.IntegerField() + + def __str__(self): + return self.tag.label_slug+":to:"+self.revision.revision_guid class Collection(models.Model): @@ -42,7 +47,9 @@ class Item(models.Model): collection = models.ForeignKey(Collection, related_name="items") item_guid = models.UUIDField(default=uuid.uuid4, editable=False) - + + def __str__(self): + return str(self.item_guid)+":from:"+self.collection.name class ItemMetadata(models.Model): item = models.OneToOneField('Item', related_name='metadatas') @@ -62,6 +69,9 @@ @property def get_joconde_url(self): return self.joconde_ref + + def __str__(self): + return "metadatas:for:"+str(self.item.item_guid) class ImageStats(models.Model): @@ -73,6 +83,9 @@ folders_inclusion_count = models.IntegerField(blank=True, null=True, default=0) tag_count = models.IntegerField(blank=True, null=True, default=0) + def __str__(self): + return "stats:for:"+self.image.image_guid + def set_tags_stats(self): self.tag_count = Tag.objects.filter(tagginginfo__revision__annotation__image = self.image).distinct().count() @@ -106,7 +119,10 @@ height = models.IntegerField(null=False, blank=False) width = models.IntegerField(null=False, blank=False) created = models.DateTimeField(auto_now_add=True, null=True) - + + def __str__(self): + return str(self.image_guid)+":"+self.name + @property def collection(self): return self.item.collection.name @@ -139,9 +155,6 @@ def measurements(self): return self.item.metadatas.measurements - def __str__(self): - return self.name - @property def tags(self): tag_list = [] @@ -196,6 +209,9 @@ comments_count = models.IntegerField(blank=True, null=True, default=0) tag_count = models.IntegerField(blank=True, null=True, default=0) + def __str__(self): + return "stats:for:"+str(self.annotation_guid) + @property def contributors(self): user_ids_list = self.annotation.revisions.filter(state__in=[AnnotationRevision.ACCEPTED, AnnotationRevision.STUDIED]).values_list("author__id", flat=True) @@ -241,6 +257,9 @@ objects = AnnotationManager() + def __str__(self): + return str(self.annotation_guid)+":"+self.current_revision.title + @property def awaiting_revisions_count(self): return self.revisions.filter(state=AnnotationRevision.AWAITING).distinct().count() @@ -334,6 +353,9 @@ state = models.IntegerField(choices=REVISION_STATES, default=AWAITING) created = models.DateTimeField(auto_now_add=True, null=True) + def __str__(self): + return str(self.revision_guid)+":"+self.title + def set_tags(self, tags_json_string): try: tags_dict = json.loads(tags_json_string) @@ -442,6 +464,9 @@ objects = XtdComment.objects + def __str__(self): + return self.id + class Meta: ordering = ["thread_id", "id"] @@ -470,13 +495,15 @@ triggers_notifications = models.IntegerField(choices=NOTIFIED_USERS, default=NONE) def __str__(self): - return self.label + return self.label+":from:"+self.collection.name class MetaCategoryInfo(models.Model): comment = models.ForeignKey('IconolabComment', on_delete=models.CASCADE) metacategory = models.ForeignKey('MetaCategory', on_delete=models.CASCADE) - + + def __str__(self): + return "metacategory:"+self.metacategory.label+":on:"+self.comment.id class CommentAttachement(models.Model): @@ -494,5 +521,8 @@ data = models.TextField(blank=False) class UserProfile(models.Model): - user = models.ForeignKey(User, related_name='user', on_delete=models.CASCADE) - administers_collection = models.ForeignKey('Collection', related_name='collection', blank=True, null=True) \ No newline at end of file + user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE) + administers_collection = models.ForeignKey('Collection', related_name='collection', blank=True, null=True) + + def __str__(self): + return "profile:"+self.user.username \ No newline at end of file diff -r 4728f6c0102e -r 088195b2a6cc src/iconolab/templates/iconolab/user_home.html --- a/src/iconolab/templates/iconolab/user_home.html Tue Aug 16 17:02:57 2016 +0200 +++ b/src/iconolab/templates/iconolab/user_home.html Wed Aug 17 14:38:22 2016 +0200 @@ -9,8 +9,8 @@ {% load notifications_tags %} {% block content %} -
-
+
+
+ {% if profile_user == request.user and profile_user.profile.administers_collection %} +
+
+ +
+ L'accès à ces fonctionnalités n'est pas encore disponible. +
+

Administration Fond {{user.profile.administers_collection.verbose_name}}

+ +
+
+ {% endif %}
+ {% endblock %} {% block footer_js %}