# HG changeset patch # User ymh # Date 1369261022 -7200 # Node ID cd67b17d257dae9e663c5fde6a035821597a1b15 # Parent 7a8e74f819bc55e2984e814d3304c3546e7cdfd9 - correct url in template - general cleaning - activate LdtUser in admin - remove ADMIN_MEDIA_PREFIX diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/ldt/resources/content.py --- a/src/ldt/ldt/api/ldt/resources/content.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/ldt/resources/content.py Thu May 23 00:17:02 2013 +0200 @@ -1,9 +1,9 @@ -from django.conf.urls.defaults import url +from django.conf.urls import url +from itertools import groupby +from ldt.indexation import get_results_list from ldt.ldt_utils.models import Content, Media +from tastypie import fields from tastypie.resources import Bundle, ModelResource, ALL_WITH_RELATIONS, ALL -from tastypie import fields -from ldt.indexation import get_results_list -from itertools import groupby class MediaResource(ModelResource): diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/ldt/resources/project.py --- a/src/ldt/ldt/api/ldt/resources/project.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/ldt/resources/project.py Thu May 23 00:17:02 2013 +0200 @@ -1,12 +1,13 @@ from django.conf import settings -from django.conf.urls.defaults import url +from django.conf.urls import url from django.contrib.auth.models import Group from guardian.shortcuts import assign -from ldt.ldt_utils.models import Project -from ldt.api.ldt.authentication import SessionAuthentication, MultiAuthentication, ApiKeyAuthentication -from ldt.api.ldt.serializers.cinelabserializer import CinelabSerializer +from ldt.api.ldt.authentication import (SessionAuthentication, + MultiAuthentication, ApiKeyAuthentication) from ldt.api.ldt.resources import ContentResource from ldt.api.ldt.resources.user import UserResource +from ldt.api.ldt.serializers.cinelabserializer import CinelabSerializer +from ldt.ldt_utils.models import Project from ldt.security import protect_models, unprotect_models from ldt.security.permissionchecker import check_object_perm_for_user from tastypie import fields, http diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/ldt/resources/segment.py --- a/src/ldt/ldt/api/ldt/resources/segment.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/ldt/resources/segment.py Thu May 23 00:17:02 2013 +0200 @@ -1,5 +1,5 @@ from django.conf import settings -from django.conf.urls.defaults import url +from django.conf.urls import url from django.core.paginator import Paginator, InvalidPage from django.db.models import F, Q from ldt.indexation import get_results_list diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/ldt/resources/tag.py --- a/src/ldt/ldt/api/ldt/resources/tag.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/ldt/resources/tag.py Thu May 23 00:17:02 2013 +0200 @@ -1,5 +1,5 @@ from django.conf import settings -from django.conf.urls.defaults import url +from django.conf.urls import url from django.core.paginator import Paginator, InvalidPage from ldt.ldt_utils.models import Segment from tagging.models import Tag diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/ldt/resources/user.py --- a/src/ldt/ldt/api/ldt/resources/user.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/ldt/resources/user.py Thu May 23 00:17:02 2013 +0200 @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import url +from django.conf.urls import url from django.contrib.auth import get_user_model from tastypie.resources import Bundle, ModelResource diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/ldt/urls.py --- a/src/ldt/ldt/api/ldt/urls.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/ldt/urls.py Thu May 23 00:17:02 2013 +0200 @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, include +from django.conf.urls import patterns, include from ldt.api.ldt.resources import ProjectResource, ContentResource, SegmentResource, AnnotationResource, UserResource, TagResource from tastypie.api import Api diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/api/urls.py --- a/src/ldt/ldt/api/urls.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/api/urls.py Thu May 23 00:17:02 2013 +0200 @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, include +from django.conf.urls import patterns, include urlpatterns = patterns('', # all my other url mappings diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/admin.py --- a/src/ldt/ldt/ldt_utils/admin.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/admin.py Thu May 23 00:17:02 2013 +0200 @@ -1,5 +1,5 @@ from StringIO import StringIO -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from django.contrib import admin from django.core.management import call_command from django.http import HttpResponse diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/app_index.html --- a/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/app_index.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/app_index.html Thu May 23 00:17:02 2013 +0200 @@ -1,5 +1,4 @@ {% extends "admin/app_index.html" %} -{% load absurl %} {% load static %} {% block extrastyle %} {{ block.super }} @@ -13,18 +12,18 @@ - - - @@ -34,7 +33,7 @@
Import
Import + Import an ldt  
Reindex + Reindex  
Compute stats + Compute stats  
- diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/dumpdata.html --- a/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/dumpdata.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/dumpdata.html Thu May 23 00:17:02 2013 +0200 @@ -1,6 +1,5 @@ {% extends "admin/ldt_utils/app_action.html" %} {% load i18n %} -{% load absurl %} {# DUMP DATA #} {% block content %} {% if message %} @@ -9,8 +8,8 @@ {% endif %}
-

Click HERE if you want to download the dumpdata's json. It can be long to load. The dumpdata is full and raw, without natural keys.

+

Click HERE if you want to download the dumpdata's json. It can be long to load. The dumpdata is full and raw, without natural keys.

-Back to administration page +Back to administration page {% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/reindex_form.html --- a/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/reindex_form.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/reindex_form.html Thu May 23 00:17:02 2013 +0200 @@ -1,6 +1,5 @@ {% extends "admin/ldt_utils/app_action.html" %} {% load i18n %} -{% load absurl %} {# reindex contents #} {% block content %} {% if message %} @@ -12,13 +11,13 @@ {% endif %}
{% csrf_token %} + action="{% url 'admin:ldt_content_reindex' %}">{% csrf_token %}
Data
Dump data + Dump data  
{{ form.as_table }}
-Back to administration page +Back to administration page {% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/stats_form.html --- a/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/stats_form.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/admin/ldt_utils/content/stats_form.html Thu May 23 00:17:02 2013 +0200 @@ -1,6 +1,5 @@ {% extends "admin/ldt_utils/app_action.html" %} {% load i18n %} -{% load absurl %} {# reindex contents #} {% block content %} {% if message %} @@ -12,13 +11,13 @@ {% endif %}
{% csrf_token %} + action="{% url 'admin:ldt_project_compute_stats' %}">{% csrf_token %} {{ form.as_table }}
-Back to administration page +Back to administration page {% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu May 23 00:17:02 2013 +0200 @@ -98,7 +98,7 @@ {% for content in results.object_list %}
  • {{ content.nb_annotations }}
    -

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    +

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    {% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}

  • {% endfor %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Thu May 23 00:17:02 2013 +0200 @@ -1,26 +1,24 @@ {% extends "ldt/ldt_utils/workspace_base.html" %} {% load i18n %} {% load static %} -{% load absurl %} - {# form of creation of content #} -{% load adminmedia %} +{# form of creation of content #} {% block js_import %} {{ block.super }} - - - + + + - - - + + + {{ content_form.media.js }} {% endblock %} {% block js_declaration %} - - + + + {{ content_form.media.js }} {% endblock %} @@ -44,7 +42,7 @@ $( this ).find("button[type=submit]").removeClass("e-clicked"); }); - var search_url = "{% absurl 'ldt.ldt_utils.views.workspace.share_filter' filter='__FILTER__' use_groups='false' %}"; + var search_url = "{% url 'ldt.ldt_utils.views.workspace.share_filter' filter='__FILTER__' use_groups='false' %}"; }); @@ -55,7 +53,7 @@
    {% if group_id %}{% trans "Update a group" %}{% else %}{% trans "Create a group" %}{% endif %}
    -
    + {% csrf_token %} @@ -67,9 +65,7 @@ {% endfor %} - +
    {% include "ldt/ldt_utils/partial/permissions.html" %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html Thu May 23 00:17:02 2013 +0200 @@ -1,7 +1,6 @@ {% extends "ldt/ldt_raw_base.html" %} {% load static %} {% load i18n %} {# form of creation of content #} -{% load adminmedia %} {% block js_import %} {{ block.super }} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/groups.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/groups.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/groups.html Thu May 23 00:17:02 2013 +0200 @@ -15,9 +15,9 @@ var groups_filter_url = "{% url 'ldt.ldt_utils.views.group.groups_filter' filter='__FILTER__' %}"; var content_filter_url = "{% url 'ldt.ldt_utils.views.content.contents_filter' filter_c='__FILTER__' %}"; var project_filter_url = "{% url 'ldt.ldt_utils.views.project.projects_filter' filter='__FILTER__' is_owner='false' status='0' id_group='__ID_GROUP__' %}"; -var publish_project_url = "{% url 'ldt.ldt_utils.views.project.publish' '__PROJECT_ID__' %}"; -var unpublish_project_url = "{% url 'ldt.ldt_utils.views.project.unpublish' '__PROJECT_ID__' %}"; -var get_group_projects_url = "{% url 'ldt.ldt_utils.views.group.get_group_projects' %}"; +var publish_project_url = "{% url 'ldt.ldt_utils.views.project.publish' id='__PROJECT_ID__' %}"; +var unpublish_project_url = "{% url 'ldt.ldt_utils.views.project.unpublish' id='__PROJECT_ID__' %}"; +var get_group_projects_url = "{% url 'ldt.ldt_utils.views.group.get_group_projects_view' %}"; function init_events(base_node) { init_events_projects(base_node, "{% url 'ldt.ldt_utils.views.workspace.popup_embed' %}", project_filter_url, publish_project_url, unpublish_project_url) diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/contentslist.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/contentslist.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/contentslist.html Thu May 23 00:17:02 2013 +0200 @@ -26,8 +26,8 @@ {% for content in contents %} -
    {% trans 'create project' %}
    -
    {% trans 'preview media'%}
    +
    {% trans 'create project' %}
    +
    {% trans 'preview media'%}
    {% thumbnail content.image "50x50" format="PNG" crop="top" as im %}{% endthumbnail %} {{ content.title|default:"_" }} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/groupslist.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/groupslist.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/groupslist.html Thu May 23 00:17:02 2013 +0200 @@ -45,7 +45,7 @@ {% if group.change %} - + {% thumbnail group.profile.image "50x50" crop="center" format="PNG" as im %}{% empty %} {% endthumbnail %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/ldt_div.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/ldt_div.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/ldt_div.html Thu May 23 00:17:02 2013 +0200 @@ -32,8 +32,8 @@ {% else %} readOnly:'true', {% endifequal %} - segmentPassMask:"{% absurl 'ldt.ldt_utils.views.lignesdetemps.index_segment' '{4}' '{0}' '{1}' '{2}' '{3}' %}", - simplePlayerPassMask:"{% absurl 'ldt.ldt_utils.views.front.annot_content' '{0}' '{4}' '{2}' %}#id={3}" + segmentPassMask:"{% absurl 'ldt.ldt_utils.views.lignesdetemps.index_segment' project_id='{4}' content_id='{0}' cutting_id='{1}' ensemble_id='{2}' segment_id='{3}' %}", + simplePlayerPassMask:"{% absurl 'ldt.ldt_utils.views.front.annot_content' content_iri_id='{0}' project_id='{4}' cutting_id='{2}' %}#id={3}" }; diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html Thu May 23 00:17:02 2013 +0200 @@ -18,9 +18,9 @@ {% for project in projects %} - {% url 'ldt.ldt_utils.views.json.project_json_id' project.ldt_id as json_url_id %} + {% url 'ldt.ldt_utils.views.json.project_json_id' id=project.ldt_id as json_url_id %} {% if is_gecko %} -
    + {% else %} -
    + {% endif %} -
    {% trans 'copy project' %}
    +
    {% trans 'copy project' %}
    {% if project.state == 2 %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/publishedprojectslist.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/publishedprojectslist.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/publishedprojectslist.html Thu May 23 00:17:02 2013 +0200 @@ -17,13 +17,13 @@ {% for project in projects %} - {% url 'ldt.ldt_utils.views.json.project_json_id' project.ldt_id as json_url_id %} + {% url 'ldt.ldt_utils.views.json.project_json_id' id=project.ldt_id as json_url_id %} {% if is_gecko %} -
    {% trans 'open ldt' %}
    +
    {% trans 'open ldt' %}
    {% else %} -
    {% trans 'open ldt' %}
    +
    {% trans 'open ldt' %}
    {% endif %} -
    {% trans 'copy the project' %}
    +
    {% trans 'copy the project' %}
    diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/published_projects.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/published_projects.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/published_projects.html Thu May 23 00:17:02 2013 +0200 @@ -14,8 +14,8 @@ var content_filter_url = "{% url 'ldt.ldt_utils.views.content.contents_filter' filter_c='__FILTER__' %}"; var project_filter_url = "{% url 'ldt.ldt_utils.views.project.projects_filter' filter='__FILTER__' is_owner='false' status='2' %}"; -var publish_project_url = "{% url 'ldt.ldt_utils.views.project.publish' '__PROJECT_ID__' %}"; -var unpublish_project_url = "{% url 'ldt.ldt_utils.views.project.unpublish' '__PROJECT_ID__' %}"; +var publish_project_url = "{% url 'ldt.ldt_utils.views.project.publish' id='__PROJECT_ID__' %}"; +var unpublish_project_url = "{% url 'ldt.ldt_utils.views.project.unpublish' id='__PROJECT_ID__' %}"; function init_events(base_node) { diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html Thu May 23 00:17:02 2013 +0200 @@ -1,6 +1,5 @@ {% extends "ldt/ldt_base.html" %} {% load i18n %} -{% load absurl %} {% block js_declaration %} {% endif %} - + {% if add %} {{ media }} {% endblock %} -{% block extrastyle %}{{ block.super }}{% endblock %} +{% block extrastyle %}{{ block.super }}{% endblock %} {% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/templates/admin/page_change_list.html --- a/src/ldt/ldt/templates/admin/page_change_list.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/templates/admin/page_change_list.html Thu May 23 00:17:02 2013 +0200 @@ -1,11 +1,11 @@ {% extends "admin/page_base_site.html" %} -{% load adminmedia admin_list i18n %} +{% load static admin_list i18n %} {% block extrastyle %} {{ block.super }} - + {% if cl.formset %} - + {% endif %} {{ media }} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/templates/admin/page_index.html --- a/src/ldt/ldt/templates/admin/page_index.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/templates/admin/page_index.html Thu May 23 00:17:02 2013 +0200 @@ -1,7 +1,7 @@ {% extends "admin/page_base_site.html" %} {% load i18n %} -{% block extrastyle %}{{ block.super }}{% endblock %} +{% block extrastyle %}{{ block.super }}{% endblock %} {% block coltype %}colMS{% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/templates/admin/page_login.html --- a/src/ldt/ldt/templates/admin/page_login.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/templates/admin/page_login.html Thu May 23 00:17:02 2013 +0200 @@ -1,7 +1,7 @@ {% extends "admin/page_base_site.html" %} {% load i18n %} -{% block extrastyle %}{% load adminmedia %}{{ block.super }}{% endblock %} +{% block extrastyle %}{% load static %}{{ block.super }}{% endblock %} {% block bodyclass %}{% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/templates/cms/admin/cms/page/change_form.html --- a/src/ldt/ldt/templates/cms/admin/cms/page/change_form.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/templates/cms/admin/cms/page/change_form.html Thu May 23 00:17:02 2013 +0200 @@ -1,11 +1,11 @@ {% extends "admin/base_site.html" %} -{% load i18n admin_modify adminmedia cms_admin %} +{% load i18n admin_modify static cms_admin %} {% block extrahead %}{{ block.super }} {% for js in javascript_imports %}{% include_admin_script js %}{% endfor %} {% endblock %} -{% block stylesheet %}{% admin_media_prefix %}css/forms.css" /> - +{% trans 'Documentation' %} / {% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %} diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/text/urls.py --- a/src/ldt/ldt/text/urls.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/text/urls.py Thu May 23 00:17:02 2013 +0200 @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url # Uncomment the next two lines to enable the admin: # from django.contrib import admin diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/user/admin.py --- a/src/ldt/ldt/user/admin.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/user/admin.py Thu May 23 00:17:02 2013 +0200 @@ -1,17 +1,20 @@ from django.contrib import admin -from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from guardian.admin import GuardedModelAdmin +from ldt.user.models import LdtUser from models import GroupProfile -User = get_user_model() - class GroupProfileInline(admin.StackedInline): model = GroupProfile class GroupAdmin(GuardedModelAdmin): inlines = [GroupProfileInline, ] +class LdtUserAdmin(admin.ModelAdmin): + pass + admin.site.unregister(Group) -admin.site.register(Group, GroupAdmin) \ No newline at end of file +admin.site.register(Group, GroupAdmin) + +admin.site.register(LdtUser, LdtUserAdmin) \ No newline at end of file diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/user/forms.py --- a/src/ldt/ldt/user/forms.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/user/forms.py Thu May 23 00:17:02 2013 +0200 @@ -1,10 +1,123 @@ from django import forms from django.conf import settings from django.contrib.auth import get_user_model +from django.contrib.auth.forms import UserCreationForm, UserChangeForm +from django.contrib.auth.models import Group +from django.forms.util import ErrorList from django.utils.translation import gettext as _ -from django.contrib.auth.models import Group User = get_user_model() + +class LdtForm(UserCreationForm): + + class Meta: + model = User + + 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 + + +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 class PictureForm(forms.Form): image=forms.ImageField(label=_("Profile picture"), required=False) diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/user/models.py --- a/src/ldt/ldt/user/models.py Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/user/models.py Thu May 23 00:17:02 2013 +0200 @@ -1,12 +1,11 @@ from django.conf import settings -from django.contrib.auth.models import (AbstractUser, User, UserManager, Group, +from django.contrib.auth.models import (AbstractUser, 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 - class LdtUserManager(BaseUserManager): def create_user(self, username, email=None, password=None, **extra_fields): @@ -46,9 +45,11 @@ profile = GroupProfile() profile.group_id = instance.id profile.save() - admins = User.objects.filter(is_superuser=True) + admins = LdtUser.objects.filter(is_superuser=True) if admins: - instance.user_set.add(admins[0]) + admin_user = admins[0] + admin_user.groups.add(instance) + admin_user.save() class LdtUser(AbstractUser): language = models.CharField(max_length=2, default=settings.LANGUAGE_CODE[:2]) diff -r 7a8e74f819bc -r cd67b17d257d src/ldt/ldt/user/templates/ldt/user/login_form.html --- a/src/ldt/ldt/user/templates/ldt/user/login_form.html Tue May 21 17:20:25 2013 +0200 +++ b/src/ldt/ldt/user/templates/ldt/user/login_form.html Thu May 23 00:17:02 2013 +0200 @@ -1,11 +1,10 @@ {% load i18n %} -{% load absurl %} {# print user's state and form of login #} {% block js_import %} {{block.super}}