--- a/.settings/org.eclipse.core.resources.prefs Wed May 15 10:05:17 2013 +0200
+++ b/.settings/org.eclipse.core.resources.prefs Mon May 20 18:02:37 2013 +0200
@@ -35,6 +35,7 @@
encoding//src/ldt/ldt/ldt_utils/migrations/0024_auto__chg_field_tag_name.py=utf-8
encoding//src/ldt/ldt/ldt_utils/migrations/0025_chg_site_domain.py=utf-8
encoding//src/ldt/ldt/ldt_utils/migrations/0026_set_relative_ldtproject.py=utf-8
+encoding//src/ldt/ldt/ldt_utils/migrations/0027_auto__chg_field_project_owner__chg_field_media_creator.py=utf-8
encoding//src/ldt/ldt/ldt_utils/views/json.py=utf-8
encoding//src/ldt/ldt/management/commands/synciri.py=utf-8
encoding//src/ldt/ldt/management/commands/updateiriurlinprojects.py=utf-8
@@ -43,6 +44,12 @@
encoding//src/ldt/ldt/text/migrations/0001_initial.py=utf-8
encoding//src/ldt/ldt/text/migrations/0002_auto__chg_field_annotation_external_id.py=utf-8
encoding//src/ldt/ldt/user/migrations/0001_initial.py=utf-8
+encoding//src/ldt/ldt/user/migrations/0005_add_permission_owner_group.py=utf-8
encoding//src/ldt/ldt/user/migrations/0008_auto__chg_field_groupprofile_image__chg_field_groupprofile_group__chg_.py=utf-8
+encoding//src/ldt/ldt/user/migrations/0009_rename_auth_user_to_user_ldt_user.py=utf-8
+encoding//src/ldt/ldt/user/migrations/0010_auto__add_field_ldtuser_language__add_field_ldtuser_image.py=utf-8
+encoding//src/ldt/ldt/user/migrations/0011_copy_image_language_ldt_user.py=utf-8
+encoding//src/ldt/ldt/user/migrations/0012_auto__del_userprofile.py=utf-8
+encoding//src/ldt/ldt/user/migrations/0013_auto__del_ldt.py=utf-8
encoding//virtualenv/web/env/guardianenv/Lib/site-packages/guardian/migrations/0001_initial.py=utf-8
encoding/<project>=UTF-8
--- a/src/ldt/ldt/api/ldt/resources/user.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/api/ldt/resources/user.py Mon May 20 18:02:37 2013 +0200
@@ -1,7 +1,9 @@
-from django.contrib.auth.models import User
from django.conf.urls.defaults import url
+from django.contrib.auth import get_user_model
from tastypie.resources import Bundle, ModelResource
+User = get_user_model()
+
class UserResource(ModelResource):
class Meta:
allowed_methods = ['get']
--- a/src/ldt/ldt/auth/__init__.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/auth/__init__.py Mon May 20 18:02:37 2013 +0200
@@ -1,3 +1,6 @@
+from django.conf import settings
+from social_auth.backends import get_backends
+
def check_access(user, obj):
check_meth = getattr(obj, 'check_access', False)
@@ -5,3 +8,13 @@
return check_meth(user)
else:
return user.is_staff
+
+def social_list():
+ """Start list process"""
+ l = []
+ # We list all wanted backends among all availables
+ for backend in get_backends():
+ for backend_str in settings.AUTHENTICATION_BACKENDS:
+ if backend in backend_str:
+ l.append(backend)
+ return l
\ No newline at end of file
--- a/src/ldt/ldt/auth/views.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/auth/views.py Mon May 20 18:02:37 2013 +0200
@@ -1,8 +1,7 @@
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.views import login as django_login
-from social_auth.views import list as social_list
-
+from ldt.auth import social_list
def login(request, template_name='registration/login.html',
redirect_field_name=REDIRECT_FIELD_NAME,
--- a/src/ldt/ldt/core/models.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/core/models.py Mon May 20 18:02:37 2013 +0200
@@ -1,9 +1,8 @@
-from django.contrib.auth.models import User
from django.db import models
-
+from django.conf import settings
class Document(models.Model):
- owner = models.ForeignKey(User, blank=True, null=True)
+ owner = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True)
class Meta:
abstract = True
--- a/src/ldt/ldt/indexation/__init__.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/indexation/__init__.py Mon May 20 18:02:37 2013 +0200
@@ -5,8 +5,6 @@
from haystack.query import SearchQuerySet
from ldt.indexation.highlighter import LdtHighlighter as Highlighter
from ldt.indexation.query_parser import QueryParser
-from ldt.ldt_utils.models import Segment
-from ldt.text.models import Annotation
import re
import sys
@@ -33,6 +31,9 @@
def get_results_list(field, query, highlight=True):
+ #put import here to avoid a circular dependency
+ from ldt.ldt_utils.models import Segment
+
if field == 'all':
field = 'text'
@@ -47,6 +48,9 @@
def get_result_text(field, query):
+ #put import here to avoid a circular dependency
+ from ldt.text.models import Annotation
+
if field == 'all':
field = 'text'
elif field == 'text':
--- a/src/ldt/ldt/indexation/backends/elasticsearch_backend.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/indexation/backends/elasticsearch_backend.py Mon May 20 18:02:37 2013 +0200
@@ -7,7 +7,7 @@
from haystack.backends import BaseEngine, elasticsearch_backend
from haystack.exceptions import MissingDependency
from haystack.utils import get_identifier
-from ldt.ldt_utils.models import Segment
+#from ldt.ldt_utils.models import Segment
import collections
try:
import requests
@@ -43,7 +43,7 @@
if highlight:
fields_def = { }
- if models is None or len(models) == 0 or Segment in models:
+ if models is None or len(models) == 0 :#or Segment in models:
fields_def['tags'] = {}
fields_def['title'] = {}
fields_def['abstract'] = {}
--- a/src/ldt/ldt/indexation/signals.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/indexation/signals.py Mon May 20 18:02:37 2013 +0200
@@ -6,8 +6,6 @@
'''
from django.db import models
from haystack import signals
-from ldt.ldt_utils.models import Segment
-from ldt.text.models import Annotation
class LdtSignalProcessor(signals.BaseSignalProcessor):
@@ -20,13 +18,20 @@
models.signals.post_delete.disconnect(self.handle_delete, sender=klass)
- def setup(self):
+ def setup(self):
+ #put import here to avoid circular
+ from ldt.ldt_utils.models import Segment
+ from ldt.text.models import Annotation
+
self.__connect_signals(Segment)
self.__connect_signals(Annotation)
def teardown(self):
+ from ldt.ldt_utils.models import Segment
+ from ldt.text.models import Annotation
+
self.__disconnect_signals(Annotation)
self.__disconnect_signals(Segment)
\ No newline at end of file
--- a/src/ldt/ldt/ldt_utils/middleware/userprofile.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/middleware/userprofile.py Mon May 20 18:02:37 2013 +0200
@@ -6,8 +6,7 @@
def process_request(self, request):
if request.user.is_authenticated():
- profile = request.user.get_profile()
- language = profile.language
+ language = request.user.language
else:
language = settings.LANGUAGE_CODE[:2]
request.user.is_regular = False
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/ldt_utils/migrations/0027_auto__chg_field_project_owner__chg_field_media_creator.py Mon May 20 18:02:37 2013 +0200
@@ -0,0 +1,160 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+
+
+class Migration(SchemaMigration):
+
+ depends_on = (
+ ("user", "0009_rename_auth_user_to_user_ldt_user"),
+ )
+
+ def forwards(self, orm):
+
+ # Changing field 'Project.owner'
+ db.alter_column(u'ldt_utils_project', 'owner_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['user.LdtUser'], null=True)) # @UndefinedVariable
+
+ # Changing field 'Media.creator'
+ db.alter_column(u'ldt_utils_media', 'creator_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['user.LdtUser'], null=True)) # @UndefinedVariable
+
+ def backwards(self, orm):
+
+ # Changing field 'Project.owner'
+ db.alter_column(u'ldt_utils_project', 'owner_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True)) # @UndefinedVariable
+
+ # Changing field 'Media.creator'
+ db.alter_column(u'ldt_utils_media', 'creator_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True)) # @UndefinedVariable
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'ldt_utils.author': {
+ 'Meta': {'object_name': 'Author'},
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
+ 'firstname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
+ 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lastname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'})
+ },
+ u'ldt_utils.content': {
+ 'Meta': {'ordering': "['title']", 'object_name': 'Content'},
+ 'authors': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['ldt_utils.Author']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'content_creation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'duration': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'front_project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['ldt_utils.Project']", 'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/contents/content_default_icon.png'", 'max_length': '200'}),
+ 'iri_id': ('django.db.models.fields.CharField', [], {'default': "u'ed941038-be29-11e2-8b76-58b035f6b93d'", 'unique': 'True', 'max_length': '255'}),
+ 'iriurl': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+ 'media_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['ldt_utils.Media']", 'null': 'True', 'blank': 'True'}),
+ 'tags': ('tagging.fields.TagField', [], {'max_length': '2048', 'null': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'update_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
+ },
+ u'ldt_utils.contentstat': {
+ 'Meta': {'object_name': 'ContentStat'},
+ 'annotation_volume_str': ('django.db.models.fields.CommaSeparatedIntegerField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'content': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'stat_annotation'", 'unique': 'True', 'to': u"orm['ldt_utils.Content']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_annotated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'blank': 'True'}),
+ 'nb_annotations': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
+ 'polemics_volume_str': ('django.db.models.fields.CommaSeparatedIntegerField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'})
+ },
+ u'ldt_utils.media': {
+ 'Meta': {'object_name': 'Media'},
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['user.LdtUser']", 'null': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'duration': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'external_id': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'external_permalink': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'external_publication_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'external_src_url': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'media_creation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'mimetype_field': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
+ 'src': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+ 'src_hash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'update_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'videopath': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'})
+ },
+ u'ldt_utils.project': {
+ 'Meta': {'ordering': "['title']", 'object_name': 'Project'},
+ 'changed_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
+ 'contents': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['ldt_utils.Content']", 'symmetrical': 'False'}),
+ 'created_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/projects/project_default_icon.png'", 'max_length': '200'}),
+ 'ldt': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'ldt_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'modification_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['user.LdtUser']", 'null': 'True', 'blank': 'True'}),
+ 'state': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
+ },
+ u'ldt_utils.segment': {
+ 'Meta': {'object_name': 'Segment'},
+ 'abstract': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'audio_href': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}),
+ 'audio_src': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'content': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['ldt_utils.Content']"}),
+ 'cutting_id': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}),
+ 'date': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
+ 'duration': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
+ 'element_id': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}),
+ 'ensemble_id': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'id_hash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}),
+ 'iri_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'polemics': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+ 'project_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'project_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['ldt_utils.Project']", 'null': 'True'}),
+ 'start_ts': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
+ 'tags': ('tagging.fields.TagField', [], {'max_length': '2048', 'null': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'})
+ },
+ u'user.ldtuser': {
+ 'Meta': {'object_name': 'LdtUser'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ }
+ }
+
+ complete_apps = ['ldt_utils']
\ No newline at end of file
--- a/src/ldt/ldt/ldt_utils/models.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/models.py Mon May 20 18:02:37 2013 +0200
@@ -1,5 +1,8 @@
+from .events import post_project_save
from django.conf import settings
-from django.contrib.auth.models import User, Group
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group
+from django.core.files.storage import default_storage
from django.db import models
from django.utils.translation import ugettext_lazy as _
from guardian.shortcuts import assign, remove_perm, get_perms
@@ -8,13 +11,13 @@
get_current_user)
from ldt.security.manager import SafeManager
from ldt.security.models import SafeModel
-from ldt.utils import url as url_utils
+from ldt.utils import generate_hash, url as url_utils
+from ldt.utils.web_url_management import get_web_url
+from shutil import move
from sorl.thumbnail import ImageField
from tagging.models import Tag
from utils import (create_ldt, copy_ldt, create_empty_iri, update_iri,
generate_uuid)
-from ldt.utils import generate_hash
-from ldt.utils.web_url_management import get_web_url
import datetime
import lxml.etree #@UnresolvedImport
import mimetypes
@@ -22,10 +25,8 @@
import re
import tagging.fields
import uuid
-from shutil import move
-from django.core.files.storage import default_storage
-from .events import post_project_save
+User = get_user_model()
class Author(SafeModel):
@@ -63,7 +64,7 @@
update_date = models.DateTimeField(auto_now=True, verbose_name=_('media.update_date'))
videopath = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('media.videopath'))
duration = models.IntegerField(null=True, blank=True, verbose_name=_('media.duration'))
- creator = models.ForeignKey(User, blank=True, null=True, verbose_name=_('media.creator'))
+ creator = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, verbose_name=_('media.creator'))
description = models.TextField(null=True, blank=True, verbose_name=_('description'))
title = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('title'))
src = models.CharField(max_length=1024, verbose_name=_('media.src'))
--- a/src/ldt/ldt/ldt_utils/projectserializer.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/projectserializer.py Mon May 20 18:02:37 2013 +0200
@@ -1,14 +1,17 @@
from datetime import datetime
from django.conf import settings
+from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.utils.datastructures import SortedDict
-from ldt.ldt_utils.models import Content, User, Project
+from ldt.ldt_utils.models import Content, Project
from ldt.ldt_utils.stat import get_string_from_buckets
from ldt.ldt_utils.utils import reduce_text_node
import logging
import lxml.etree
import uuid
+User = get_user_model()
+
DATE_FORMATS = ["%d/%m/%Y", "%Y-%m-%d"]
logger = logging.getLogger(__name__)
--- a/src/ldt/ldt/ldt_utils/templates/front/front_group.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_group.html Mon May 20 18:02:37 2013 +0200
@@ -118,7 +118,7 @@
<ul class="floatlist" id="membres_groupes">
{% for user in users %}
<li class="li_membre_groupe">
- {% thumbnail user.get_profile.image "36x36" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" title="{{user.username}}" alt="{{user.username}}">{% endthumbnail %}
+ {% thumbnail user.image "36x36" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" title="{{user.username}}" alt="{{user.username}}">{% endthumbnail %}
<p><b>{{user.username}}</b></p>
<p class="font_11">{% trans 'active since' %} {{user.date_joined|date:"Y/m/d"}}</p>
</li>
--- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Mon May 20 18:02:37 2013 +0200
@@ -104,7 +104,7 @@
<!-- Active groups -->
<ul class="floatlist" id="groupes_actifs">
<li class="li_h2">
- <h2><a href="{% url ldt.ldt_utils.views.front.group_list %}">{% trans 'Active groups' %}</a></h2>
+ <h2><a href="{% url 'ldt.ldt_utils.views.front.group_list' %}">{% trans 'Active groups' %}</a></h2>
</li>
{% for group in active_groups %}
<li class="li_media">
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed_iframe.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed_iframe.html Mon May 20 18:02:37 2013 +0200
@@ -161,7 +161,7 @@
close_after_send: false,
slice_annotation_type: ["chap","découpage"],
creator_name: '{{request.user.username}}',
- creator_avatar: '{% thumbnail request.user.get_profile.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png"
+ creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png"
}{% endif %}
{% if slideshare %},{
type: "Slideshare",
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Mon May 20 18:02:37 2013 +0200
@@ -79,7 +79,7 @@
close_after_send: false,
slice_annotation_type: ["chap","découpage"],
creator_name: '{{request.user.username}}',
- creator_avatar: '{% thumbnail request.user.get_profile.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png"
+ creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png"
},{
type: "Slideshare",
container: "Slideshare_ext",
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/groupslist.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/groupslist.html Mon May 20 18:02:37 2013 +0200
@@ -65,7 +65,7 @@
{% if not user.is_superuser and not search_active %}
<tr class="clickable imageline {% cycle color_cycle %} update_group_projects" id="-1">
<td class="groupimg">
- {% thumbnail user.get_profile.image "50x50" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}
+ {% thumbnail user.image "50x50" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}
</td>
<td>{% trans "Projects shared with me only" %}</td>
--- a/src/ldt/ldt/ldt_utils/tests/content_tests.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/tests/content_tests.py Mon May 20 18:02:37 2013 +0200
@@ -6,20 +6,23 @@
"""
from django.conf import settings
+from django.contrib.auth import get_user_model, create_superuser
from django.utils._os import WindowsError
-from ldt.ldt_utils.models import User, Content, Media
+from ldt.ldt_utils.models import Content, Media
from ldt.test.client import Client
from ldt.test.testcases import TestCase
import logging
import os
+User = get_user_model()
+
class ContentTest(TestCase):
fixtures = ['base_data.json', 'user_data.json']
def setUp(self):
self.client = Client()
- User.objects.create_superuser('blop', 'blop@blop.com', 'blop')
+ create_superuser('blop', 'blop@blop.com', 'blop')
_ = self.client.login(username='blop', password='blop')
--- a/src/ldt/ldt/ldt_utils/tests/ldt_tests.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/tests/ldt_tests.py Mon May 20 18:02:37 2013 +0200
@@ -5,7 +5,8 @@
Replace these with more appropriate tests for your application.
"""
-from ldt.ldt_utils.models import User, Project, Content
+from django.contrib.auth import get_user_model
+from ldt.ldt_utils.models import Project, Content
from ldt.ldt_utils.utils import (LdtUtils, LdtAnnotation, create_ldt,
create_empty_iri, copy_ldt)
from ldt.test.client import Client
@@ -15,6 +16,8 @@
import tempfile
import uuid
+User = get_user_model()
+
class UtilsTest(TestCase):
fixtures = ['base_data.json', 'user_data.json']
--- a/src/ldt/ldt/ldt_utils/tests/media_tests.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/tests/media_tests.py Mon May 20 18:02:37 2013 +0200
@@ -5,10 +5,13 @@
Replace these with more appropriate tests for your application.
"""
-from ldt.ldt_utils.models import User, Media
+from django.contrib.auth import get_user_model
+from ldt.ldt_utils.models import Media
from ldt.test.client import Client
from ldt.test.testcases import TestCase
+User = get_user_model()
+
class MediaTest(TestCase):
fixtures = ['base_data.json', 'user_data.json']
--- a/src/ldt/ldt/ldt_utils/tests/project_tests.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/tests/project_tests.py Mon May 20 18:02:37 2013 +0200
@@ -5,14 +5,16 @@
Replace these with more appropriate tests for your application.
"""
+from django.contrib.auth import get_user_model
from django.core.management import call_command
-from ldt.ldt_utils.models import User, Project, Content
+from ldt.ldt_utils.models import Project, Content
from ldt.ldt_utils.utils import LdtUtils, LdtAnnotation, create_ldt
from ldt.test.client import Client
from ldt.test.testcases import TestCase
import lxml.etree
import uuid
+User = get_user_model()
class ProjectTest(TestCase):
--- a/src/ldt/ldt/ldt_utils/views/front.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/views/front.py Mon May 20 18:02:37 2013 +0200
@@ -1,6 +1,7 @@
from django.conf import settings
+from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
-from django.contrib.auth.models import Group, User
+from django.contrib.auth.models import Group
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.core.urlresolvers import reverse
from django.db.models import Count
@@ -9,11 +10,13 @@
from ldt.ldt_utils.forms import SearchForm
from ldt.ldt_utils.models import Content, Project
from ldt.ldt_utils.views.content import get_content_tags
+from ldt.ldt_utils.views.group import get_group_projects
from ldt.ldt_utils.views.workspace import get_search_results
from ldt.utils.url import static
from tagging.models import TaggedItem
import logging
+User = get_user_model()
logger = logging.getLogger(__name__)
@@ -23,7 +26,7 @@
# Get the most annotated contents
most_contents = Content.safe_objects.order_by('-stat_annotation__nb_annotations').select_related('stat_annotation')[:8]
# Get the active groups
- active_groups = Group.objects.select_related("profile").annotate(nb_users=Count("user")).exclude(name=settings.PUBLIC_GROUP_NAME)[:5]
+ active_groups = Group.objects.select_related("profile").annotate(nb_users=Count("ldtuser")).exclude(name=settings.PUBLIC_GROUP_NAME)[:5]
# Get the main tag list
front_tags = settings.FRONT_TAG_LIST
# Get the all tags list
--- a/src/ldt/ldt/management/__init__.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/management/__init__.py Mon May 20 18:02:37 2013 +0200
@@ -1,15 +1,11 @@
from django.conf import settings
-from django.contrib.auth.models import User, Group
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import signals
-from ldt.user.models import Ldt
-
-def post_save_ldt(instance, raw, created, **kwargs):
- signals.post_save.send(sender=User, instance=instance, raw=raw, created=created)
-
-signals.post_save.connect(post_save_ldt, Ldt)
+User = get_user_model()
def post_save_user(instance, raw, created, **kwargs):
if created:
--- a/src/ldt/ldt/security/__init__.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/security/__init__.py Mon May 20 18:02:37 2013 +0200
@@ -1,14 +1,16 @@
from django.conf import settings
+from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
-from django.contrib.auth.models import User
from django.core.signals import request_started
-from ldt.security.permissionchecker import check_object_perm_for_user
+from ldt.security.permissionchecker import check_object_perm_for_user
+
+User = get_user_model()
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
-
+
_thread_locals = local()
# The function that protect models is called on the first
--- a/src/ldt/ldt/security/cache.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/security/cache.py Mon May 20 18:02:37 2013 +0200
@@ -1,13 +1,15 @@
from django.core.cache import cache
from django.conf import settings
from guardian.core import ObjectPermissionChecker
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
from django.db.models import Q
from guardian.shortcuts import assign
from django.utils.encoding import smart_str
import re
import hashlib
+User = get_user_model()
+
def get_cached_checker(user):
key_name = get_key(user.username)
--- a/src/ldt/ldt/security/command.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/security/command.py Mon May 20 18:02:37 2013 +0200
@@ -1,9 +1,12 @@
from django.conf import settings
-from django.contrib.auth.models import Group, User
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group
from guardian.shortcuts import assign, remove_perm
from ldt.ldt_utils.models import Project, Content
from ldt.management.utils import show_progress
+User = get_user_model()
+
def set_default_permissions(verbose=False, is_migration=False, orm=None):
writer = None
--- a/src/ldt/ldt/security/forms.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/security/forms.py Mon May 20 18:02:37 2013 +0200
@@ -1,7 +1,10 @@
from django import forms
-from django.contrib.auth.models import User, Group
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group
from django.forms.widgets import HiddenInput, MultipleHiddenInput
+User = get_user_model()
+
class LazyMultipleChoiceField(forms.MultipleChoiceField):
def validate(self, value):
--- a/src/ldt/ldt/security/permissionchecker.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/security/permissionchecker.py Mon May 20 18:02:37 2013 +0200
@@ -1,5 +1,5 @@
+from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
-from django.contrib.auth.models import Permission
from guardian.models import UserObjectPermission, GroupObjectPermission
--- a/src/ldt/ldt/settings.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/settings.py Mon May 20 18:02:37 2013 +0200
@@ -52,7 +52,8 @@
'ldt.ldt_utils.middleware.userprofile.LanguageMiddleware',
))
-
+AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL','user.LdtUser')
+INITIAL_CUSTOM_USER_MIGRATION = getattr(settings, 'INITIAL_CUSTOM_USER_MIGRATION','0009_rename_auth_user_to_user_ldt_user')
WEB_URL = getattr(settings, 'WEB_URL', '')
WEB_AUTH = getattr(settings, 'WEB_AUTH', [])
@@ -65,6 +66,7 @@
MANAGERS = settings.MANAGERS
INSTALLED_APPS = settings.INSTALLED_APPS
LANGUAGES = settings.LANGUAGES
+AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'user.LdtUser')
DECOUPAGE_BLACKLIST = getattr(settings, 'DECOUPAGE_BLACKLIST', 'de_PPP')
STREAM_URL = getattr(settings, 'STREAM_URL', '')
STREAM_PATH = getattr(settings, 'STREAM_PATH', '')
--- a/src/ldt/ldt/templates/ldt/ldt_base.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/templates/ldt/ldt_base.html Mon May 20 18:02:37 2013 +0200
@@ -93,7 +93,7 @@
{% if user.is_authenticated %}
<a href="{% url 'front_home' %}" title="{% trans "front link" %}">{% trans "front link" %}</a> |
<a href="{% url 'ldt.user.views.profile' %}" title="{% trans "Profile change" %}">
- {% thumbnail user.get_profile.image "20x20" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}
+ {% thumbnail user.image "20x20" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}
{{user.username}}</a>
| <a href="{% url 'ldt.user.views.logout_view' %}" title="{% trans "Log out" %}">{% trans "Log out" %}</a>
{% endif %}
--- a/src/ldt/ldt/text/models.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/text/models.py Mon May 20 18:02:37 2013 +0200
@@ -2,7 +2,7 @@
from django.utils.translation import ugettext_lazy as _
from tagging.models import Tag
from utils import generate_uuid
-import lxml
+import lxml.etree
import tagging.fields
#from django.core.management.validation import max_length
@@ -74,8 +74,8 @@
textannotation = lxml.etree.SubElement(iri, 'text-annotation')
- id = lxml.etree.SubElement(textannotation, 'id')
- id.text = self.external_id
+ id_node = lxml.etree.SubElement(textannotation, 'id')
+ id_node.text = self.external_id
uri = lxml.etree.SubElement(textannotation, 'uri')
uri.text = self.uri
--- a/src/ldt/ldt/user/admin.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/admin.py Mon May 20 18:02:37 2013 +0200
@@ -1,13 +1,10 @@
-from copy import deepcopy #@UnresolvedImport
from django.contrib import admin
-from django.contrib.auth.admin import UserAdmin
-from django.contrib.auth.models import Group, User
-from django.utils.translation import ugettext as _
-from forms import LdtForm
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group
from guardian.admin import GuardedModelAdmin
-from models import Ldt, UserProfile, GroupProfile
-from tastypie.admin import ApiKeyInline
+from models import GroupProfile
+User = get_user_model()
class GroupProfileInline(admin.StackedInline):
model = GroupProfile
@@ -15,53 +12,6 @@
class GroupAdmin(GuardedModelAdmin):
inlines = [GroupProfileInline, ]
-class UserProfileInline(admin.StackedInline):
- model = UserProfile
-
-class UserProfileAdmin(UserAdmin):
- def add_view(self, *args, **kwargs):
- self.inlines = []
- return super(UserProfileAdmin, self).add_view(*args, **kwargs)
-
- def change_view(self, *args, **kwargs):
- self.inlines = [UserProfileInline]
- return super(UserAdmin, self).change_view(*args, **kwargs)
-
-
-class LdtAdmin(UserProfileAdmin):
- list_display = ('username', 'email', 'first_name', 'last_name')
-
- fieldsets = [
- (None, {'fields': ('username', ('password1', 'password2'))}),
- (_('User details'), {'fields': (('first_name', 'last_name'), 'email')}),
- (_('Groups'), {'fields': ('groups',)}),
- (_('Permissions'), {'fields': ('is_staff', 'user_permissions')}),
- ]
- form = LdtForm
- model = Ldt
- filter_horizontal = ('user_permissions',)
- inlines = [UserProfileInline, ApiKeyInline]
-
- def get_fieldsets(self, request, obj=None):
- fieldsets = deepcopy(self.fieldsets)
- if not '/add' in request.path:
- fieldsets[0] = (None, {'fields': ('username',)})
- fieldsets.append((_('Password'), {'fields': ('password1', 'password2'), 'classes': ('collapse',)}))
- return fieldsets
-
- def add_view(self, request):
- return super(UserAdmin, self).add_view(request)
-
-
admin.site.unregister(Group)
-admin.site.register(Group, GroupAdmin)
-
-admin.site.unregister(Ldt)
-admin.site.register(Ldt, LdtAdmin)
-
-#admin.site.register(ApiKey)
-#admin.site.register(ApiAccess)
-
-admin.site.unregister(User)
-admin.site.register(User, UserProfileAdmin)
+admin.site.register(Group, GroupAdmin)
\ No newline at end of file
--- a/src/ldt/ldt/user/forms.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/forms.py Mon May 20 18:02:37 2013 +0200
@@ -1,123 +1,10 @@
from django import forms
from django.conf import settings
-from django.contrib.auth.forms import UserCreationForm, UserChangeForm
-from django.contrib.auth.models import User
-from django.forms.util import ErrorList
+from django.contrib.auth import get_user_model
from django.utils.translation import gettext as _
-from models import Ldt
-
-
-class LdtForm(UserCreationForm):
-
- class Meta:
- model = Ldt
-
- def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
- initial=None, error_class=ErrorList, label_suffix=':',
- empty_permitted=False, instance=None):
-
- if instance:
- initial = initial or {}
-
- super(LdtForm, self).__init__(data, files, auto_id, prefix,
- initial, error_class, label_suffix, empty_permitted, instance)
-
- if instance:
- self.fields['password1'].required = False
- self.fields['password1'].label = _('New password')
- self.fields['password2'].required = False
- self.fields['password2'].label = _('New password confirmation')
-
- self._password_change = True
-
- def clean_username(self):
- if self.instance:
- return self.cleaned_data['username']
- return super(LdtForm, self).clean_username()
-
- def clean_password2(self):
- if self.instance and self.cleaned_data['password1'] == '' and self.cleaned_data['password2'] == '':
- self._password_change = False
- return u''
- return super(LdtForm, self).clean_password2()
-
-
- def save(self, commit=True):
- Super = self._password_change and LdtForm or UserCreationForm
- user = super(Super, self).save(commit=False)
- # if user.pk != None:
- # self.save_m2m()
-
- if commit:
- user.save()
-
- return user
+from django.contrib.auth.models import Group
-
-class EmailChangeForm(forms.Form):
- email1 = forms.EmailField(label=_("E-mail"), max_length=75)
- email2 = forms.EmailField(label=_("E-mail"), max_length=75)
-
- def __init__(self, user=None, *args, **kwargs):
- self.user = user
- super(EmailChangeForm, self).__init__(*args, **kwargs)
-
- def clean_email2(self):
- email1 = self.cleaned_data.get('email1')
- email2 = self.cleaned_data.get('email2')
- if email1 and email2:
- if email1 != email2:
- raise forms.ValidationError(_("The two emails didn't match."))
- return email2
-
-
- def save(self):
- self.user.email = self.cleaned_data['email1']
- self.user.save()
- return self.user
-
-
-class NameChangeForm(forms.Form):
- first_name = forms.CharField(label=_("First name"), max_length=30)
- last_name = forms.CharField(label=_("Last name"), max_length=30)
-
- def __init__(self, user=None, *args, **kwargs):
- self.user = user
- super(NameChangeForm, self).__init__(*args, **kwargs)
-
-
- def save(self):
- self.user.first_name = self.cleaned_data['first_name']
- self.user.last_name = self.cleaned_data['last_name']
- self.user.save()
- return self.user
-
-
-class ProfileForm(UserChangeForm):
-
- def __init__(self, user=None, *args, **kwargs):
- #self.user = user
- super(ProfileForm, self).__init__(*args, **kwargs)
-
-
- class Meta:
- model = User
- fields = ('username', 'email', 'first_name', 'last_name', 'password')
-
-
-class LanguageChangeForm(forms.Form):
- language = forms.ChoiceField(label=_("Language"), choices=settings.LANGUAGES)
-
- def __init__(self, user=None, *args, **kwargs):
- self.user = user
- super(LanguageChangeForm, self).__init__(*args, **kwargs)
-
- def save(self):
- profile = self.user.get_profile()
- profile.language = self.cleaned_data['language']
- profile.save()
- return self.user
-
+User = get_user_model()
class PictureForm(forms.Form):
image=forms.ImageField(label=_("Profile picture"), required=False)
@@ -141,9 +28,12 @@
return None
class_name = self.model.__class__.__name__
- if class_name == 'User' or class_name == 'Group':
+ if isinstance(self.model, Group):
instance_name = "%s" % self.model.id
img_container = self.model.get_profile()
+ if isinstance(self.model, User):
+ instance_name = "%s" % self.model.id
+ img_container = self.model
elif class_name == 'Content':
instance_name = self.model.iri_id
img_container = self.model
@@ -159,5 +49,4 @@
img_container.image = self.cleaned_data['image']
img_container.save()
return self.model
-
\ No newline at end of file
--- a/src/ldt/ldt/user/migrations/0005_add_permission_owner_group.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/migrations/0005_add_permission_owner_group.py Mon May 20 18:02:37 2013 +0200
@@ -1,20 +1,14 @@
-#@PydevCodeAnalysisIgnore
# encoding: utf-8
-import datetime
-from south.db import db
+from django.contrib.auth.models import Permission
+from django.contrib.contenttypes.models import ContentType
from south.v2 import DataMigration
-from django.db import models
-from django.contrib.auth.models import User
-from ldt.user.models import UserProfile
-from django.contrib.auth.models import Group, Permission
-from django.contrib.contenttypes.models import ContentType
class Migration(DataMigration):
def forwards(self, orm):
content_type = ContentType.objects.get(app_label='auth', model='group')
- permission = Permission.objects.create(codename='is_owner_group',
+ Permission.objects.create(codename='is_owner_group',
name='Can add/delete admins to the group',
content_type=content_type)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/user/migrations/0009_rename_auth_user_to_user_ldt_user.py Mon May 20 18:02:37 2013 +0200
@@ -0,0 +1,95 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ db.rename_table('auth_user', 'user_ldtuser') # @UndefinedVariable
+ db.rename_table('auth_user_groups', 'user_ldtuser_groups') # @UndefinedVariable
+ db.rename_column('user_ldtuser_groups', 'user_id', 'ldtuser_id') # @UndefinedVariable
+ db.rename_table('auth_user_user_permissions', 'user_ldtuser_user_permissions') # @UndefinedVariable
+ db.rename_column('user_ldtuser_user_permissions', 'user_id', 'ldtuser_id') # @UndefinedVariable
+
+ def backwards(self, orm):
+ db.rename_table('user_ldt_user', 'auth_user') # @UndefinedVariable
+ db.rename_table('user_ldtuser_groups', 'auth_user_groups') # @UndefinedVariable
+ db.rename_column('auth_user_groups', 'ldtuser_id', 'user_id') # @UndefinedVariable
+ db.rename_table('user_ldtuser_user_permissions', 'auth_user_user_permissions') # @UndefinedVariable
+ db.rename_column('auth_user_user_permissions', 'ldtuser_id', 'user_id') # @UndefinedVariable
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'user.groupprofile': {
+ 'Meta': {'object_name': 'GroupProfile'},
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'group': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/groups/group_default_icon.png'", 'max_length': '200'})
+ },
+ u'user.ldt': {
+ 'Meta': {'object_name': 'Ldt', '_ormbases': [u'auth.User']},
+ u'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True', 'primary_key': 'True'})
+ },
+ u'user.ldtuser': {
+ 'Meta': {'object_name': 'LdtUser'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'user.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'})
+ }
+ }
+
+ complete_apps = ['user']
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/user/migrations/0010_auto__add_field_ldtuser_language__add_field_ldtuser_image.py Mon May 20 18:02:37 2013 +0200
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'LdtUser.language'
+ db.add_column(u'user_ldtuser', 'language', # @UndefinedVariable
+ self.gf('django.db.models.fields.CharField')(default='fr', max_length=2),
+ keep_default=False)
+
+ # Adding field 'LdtUser.image'
+ db.add_column(u'user_ldtuser', 'image', # @UndefinedVariable
+ self.gf('sorl.thumbnail.fields.ImageField')(default='thumbnails/users/user_default_icon.png', max_length=200),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'LdtUser.language'
+ db.delete_column(u'user_ldtuser', 'language') # @UndefinedVariable
+
+ # Deleting field 'LdtUser.image'
+ db.delete_column(u'user_ldtuser', 'image') # @UndefinedVariable
+
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'user.groupprofile': {
+ 'Meta': {'object_name': 'GroupProfile'},
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'group': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/groups/group_default_icon.png'", 'max_length': '200'})
+ },
+ u'user.ldt': {
+ 'Meta': {'object_name': 'Ldt', '_ormbases': [u'auth.User']},
+ u'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True', 'primary_key': 'True'})
+ },
+ u'user.ldtuser': {
+ 'Meta': {'object_name': 'LdtUser'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'user.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'})
+ }
+ }
+
+ complete_apps = ['user']
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/user/migrations/0011_copy_image_language_ldt_user.py Mon May 20 18:02:37 2013 +0200
@@ -0,0 +1,96 @@
+# -*- coding: utf-8 -*-
+from south.v2 import DataMigration
+
+class Migration(DataMigration):
+
+ def forwards(self, orm):
+ for userprofile in orm['user.userprofile'].objects.all():
+ user = orm['user.ldtuser'].objects.get(id=userprofile.user_id)
+ user.language = userprofile.language
+ user.image = userprofile.image
+ user.save()
+
+ def backwards(self, orm):
+ for user in orm['user.userprofile'].objects.all():
+ userprofile = orm['user.ldtprofile'].objects.get(user_id=user.id)
+ userprofile.language = user.language
+ userprofile.image = user.image
+ userprofile.save()
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'user.groupprofile': {
+ 'Meta': {'object_name': 'GroupProfile'},
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'group': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/groups/group_default_icon.png'", 'max_length': '200'})
+ },
+ u'user.ldt': {
+ 'Meta': {'object_name': 'Ldt', '_ormbases': [u'auth.User']},
+ u'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True', 'primary_key': 'True'})
+ },
+ u'user.ldtuser': {
+ 'Meta': {'object_name': 'LdtUser'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'user.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'})
+ }
+ }
+
+ complete_apps = ['user']
+ symmetrical = True
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/user/migrations/0012_auto__del_userprofile.py Mon May 20 18:02:37 2013 +0200
@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting model 'UserProfile'
+ db.delete_table(u'user_userprofile') # @UndefinedVariable
+
+
+ def backwards(self, orm):
+ # Adding model 'UserProfile'
+ db.create_table(u'user_userprofile', ( # @UndefinedVariable
+ ('image', self.gf('sorl.thumbnail.fields.ImageField')(default='thumbnails/users/user_default_icon.png', max_length=200)),
+ (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('language', self.gf('django.db.models.fields.CharField')(default='fr', max_length=2)),
+ ('user', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True)),
+ ))
+ db.send_create_signal(u'user', ['UserProfile']) # @UndefinedVariable
+
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'user.groupprofile': {
+ 'Meta': {'object_name': 'GroupProfile'},
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'group': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/groups/group_default_icon.png'", 'max_length': '200'})
+ },
+ u'user.ldt': {
+ 'Meta': {'object_name': 'Ldt', '_ormbases': [u'auth.User']},
+ u'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True', 'primary_key': 'True'})
+ },
+ u'user.ldtuser': {
+ 'Meta': {'object_name': 'LdtUser'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ }
+ }
+
+ complete_apps = ['user']
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/user/migrations/0013_auto__del_ldt.py Mon May 20 18:02:37 2013 +0200
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting model 'Ldt'
+ db.delete_table(u'user_ldt') # @UndefinedVariable
+
+
+ def backwards(self, orm):
+ # Adding model 'Ldt'
+ db.create_table(u'user_ldt', ( # @UndefinedVariable
+ (u'user_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True, primary_key=True)),
+ ))
+ db.send_create_signal(u'user', ['Ldt']) # @UndefinedVariable
+
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'user.groupprofile': {
+ 'Meta': {'object_name': 'GroupProfile'},
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'group': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/groups/group_default_icon.png'", 'max_length': '200'})
+ },
+ u'user.ldtuser': {
+ 'Meta': {'object_name': 'LdtUser'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ }
+ }
+
+ complete_apps = ['user']
\ No newline at end of file
--- a/src/ldt/ldt/user/models.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/models.py Mon May 20 18:02:37 2013 +0200
@@ -1,48 +1,39 @@
from django.conf import settings
-from django.contrib import admin
-from django.contrib.auth.models import User, UserManager, Group
+from django.contrib.auth.models import (AbstractUser, User, UserManager, Group,
+ BaseUserManager)
from django.db import models
from django.db.models.signals import post_save
+from django.utils import timezone
from sorl.thumbnail import ImageField
-import datetime
-
-class Ldt(User):
-# irigroups = models.ManyToManyField(IriGroup, blank=True)
-
- class Meta:
- verbose_name = 'iri user'
- verbose_name_plural = 'iri users'
-
- def __unicode__(self):
- return self.username
-
+
+class LdtUserManager(BaseUserManager):
-class LdtManager(UserManager):
- def create_user(self, username, email, password=None):
- "Creates and saves a User with the given username, e-mail and password."
- now = datetime.datetime.utcnow()
- new_user = Ldt(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now)
- if password:
- new_user.set_password(password)
- else:
- new_user.set_unusable_password()
- new_user.save()
- new_user.groups.add(Group.objects.get(name=settings.PUBLIC_GROUP_NAME))
- return new_user
-
-
-class UserProfile (models.Model):
- user = models.OneToOneField(User)
- language = models.CharField(max_length=2, default=settings.LANGUAGE_CODE[:2])
- image = ImageField(upload_to=settings.MEDIA_ROOT+"thumbnails/users/", default=settings.DEFAULT_USER_ICON, max_length=200)
+ def create_user(self, username, email=None, password=None, **extra_fields):
+ """
+ Creates and saves a User with the given username, email and password.
+ """
+ now = timezone.now()
+ if not username:
+ raise ValueError('The given username must be set')
+ email = UserManager.normalize_email(email)
+ user = self.model(username=username, email=email,
+ is_staff=False, is_active=True, is_superuser=False,
+ last_login=now, date_joined=now, **extra_fields)
- @staticmethod
- def create_user_profile(sender, instance, created, **kwargs):
- if created:
- UserProfile.objects.get_or_create(user=instance)
- everyone, _ = Group.objects.get_or_create(name=settings.PUBLIC_GROUP_NAME)
- instance.groups.add(everyone)
+ user.set_password(password)
+ user.save(using=self._db)
+ everyone, _ = Group.objects.get_or_create(name=settings.PUBLIC_GROUP_NAME)
+ user.groups.add(everyone)
+ return user
+
+ def create_superuser(self, username, email, password, **extra_fields):
+ u = self.create_user(username, email, password, **extra_fields)
+ u.is_staff = True
+ u.is_active = True
+ u.is_superuser = True
+ u.save(using=self._db)
+ return u
class GroupProfile(models.Model):
group = models.OneToOneField(Group, primary_key=False, related_name='profile')
@@ -58,17 +49,18 @@
admins = User.objects.filter(is_superuser=True)
if admins:
instance.user_set.add(admins[0])
+
+class LdtUser(AbstractUser):
+ language = models.CharField(max_length=2, default=settings.LANGUAGE_CODE[:2])
+ image = ImageField(upload_to=settings.MEDIA_ROOT+"thumbnails/users/", default=settings.DEFAULT_USER_ICON, max_length=200)
+
+ objects = LdtUserManager()
+
# To keep consistency with User.get_profile() method
def get_profile(self):
return self.profile
-Group.add_to_class("get_profile", get_profile)
-
+Group.add_to_class("get_profile", get_profile) # @UndefinedVariable
post_save.connect(GroupProfile.create_group_profile, sender=Group)
-post_save.connect(UserProfile.create_user_profile, sender=User)
-
-User.objects = LdtManager()
-User.objects.contribute_to_class(User, "objects")
-admin.site.register(Ldt)
--- a/src/ldt/ldt/user/templates/ldt/user/change_profile.html Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/templates/ldt/user/change_profile.html Mon May 20 18:02:37 2013 +0200
@@ -154,7 +154,7 @@
<strong>{% trans "Current profile picture" %}</strong>
</td>
<td>
- {% thumbnail user.get_profile.image "x100" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}
+ {% thumbnail user.image "x100" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}
</td>
</tr>
<tr>
--- a/src/ldt/ldt/user/urls.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/urls.py Mon May 20 18:02:37 2013 +0200
@@ -2,8 +2,5 @@
urlpatterns = patterns('',
url(r'^loginAjax/$', 'ldt.user.views.login_ajax'),
- url(r'^profile/$', 'ldt.user.views.profile'),
- url(r'^password/$', 'ldt.user.views.password'),
- url(r'^picture/$', 'ldt.user.views.profile_picture'),
url(r'^logout/', 'ldt.user.views.logout_view'),
)
--- a/src/ldt/ldt/user/views.py Wed May 15 10:05:17 2013 +0200
+++ b/src/ldt/ldt/user/views.py Mon May 20 18:02:37 2013 +0200
@@ -1,91 +1,15 @@
from django.contrib.auth import authenticate, login, logout
-from django.contrib.auth.decorators import login_required
-from django.contrib.auth.forms import PasswordChangeForm
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext, loader
from django.utils import simplejson
from django.utils.translation import ugettext as _
-from forms import ProfileForm, LanguageChangeForm, PictureForm
-from django.views.i18n import set_language
-@login_required
-def profile(request):
- msg = ''
- profile = request.user.get_profile()
- user_language = profile.language
-
- if request.method == "POST":
- profile_form = ProfileForm(request.user, request.POST, instance=request.user)
- language_form = LanguageChangeForm(request.user, request.POST)
- password_form = PasswordChangeForm(request.user)
- if profile_form.is_valid() and language_form.is_valid():
- profile_form.save()
- language_form.save()
- set_language(request)
- msg = _("Your profile has been updated.")
- user_language = language_form.cleaned_data['language']
-
- else:
- language_form = LanguageChangeForm()
- profile_form = ProfileForm(instance=request.user)
- password_form = PasswordChangeForm(request.user)
- profile_picture_form = PictureForm()
-
- return render_to_response('ldt/user/change_profile.html', {'profile_form' : profile_form, 'language_form' : language_form, 'password_form' : password_form, 'user_language' : user_language, 'profile_picture_form':profile_picture_form, 'msg' : msg }, context_instance=RequestContext(request))
-
-
-@login_required
-def password(request):
- msg = ''
- user_language = request.user.get_profile().language
-
- if request.method == "POST":
- password_form = PasswordChangeForm(request.user, request.POST)
- profile_form = ProfileForm(instance=request.user)
- language_form = LanguageChangeForm()
- if password_form.is_valid():
- password_form.save()
- msg = _("Your password has been updated.")
-
- else:
- language_form = LanguageChangeForm()
- profile_form = ProfileForm()
- password_form = PasswordChangeForm(request.user)
-
- profile_picture_form = PictureForm()
-
- return render_to_response('ldt/user/change_profile.html', {'profile_form' : profile_form, 'language_form' : language_form, 'password_form' : password_form, 'user_language' : user_language, 'profile_picture_form':profile_picture_form, 'msg' : msg }, context_instance=RequestContext(request))
-
-
-@login_required
-def profile_picture(request):
- msg = ''
- user_language = request.user.get_profile().language
-
- if request.method == "POST":
- profile_form = ProfileForm(instance=request.user)
- language_form = LanguageChangeForm(request.user, request.POST)
- password_form = PasswordChangeForm(request.user)
- profile_picture_form = PictureForm(request.user, request.POST, request.FILES)
- if profile_picture_form.is_valid():
- profile_picture_form.save()
- msg = _("Your profile picture has been updated.")
-
- else:
- language_form = LanguageChangeForm()
- profile_form = ProfileForm()
- password_form = PasswordChangeForm(request.user)
- profile_picture_form = PictureForm()
-
- return render_to_response('ldt/user/change_profile.html', {'profile_form' : profile_form, 'language_form' : language_form, 'password_form' : password_form, 'user_language' : user_language, 'profile_picture_form':profile_picture_form, 'msg' : msg }, context_instance=RequestContext(request))
-
def logout_view(request):
logout(request)
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
#return HttpResponseRedirect(settings.LOGOUT_URL)
-
def login_ajax(request, loginstate_template_name='ldt/user/login_form.html'):
if request.method == "POST":