Models for Project Sheet
Answer(id, question_id, project_id)
AnswerTranslation(id, content, language_code, master_id)
Root object for a project. Holds only shared data
A translation of a project
ObjectiveTranslation(id, name, language_code, master_id)
A picture illustrating a project (jpg, png accepted)
A reference, such as a book or URL, for a Project Sheet
An embeddable Video for a project
QuestionTranslation(id, content, language_code, master_id)
TagCMS(id, placeholder_id, parent_id, position, language, plugin_type, creation_date, level, lft, rght, tree_id, cmsplugin_ptr_id, tag_id)
A topic is a project type, aka. Template.
TopicTranslation(id, label, language_code, master_id)
When the last translation of a project is deleted, delete the project.
Generate a random UUID for a picture, use the uuid as the track name
alias of I4pProject
Django Forms for a Project Sheet
Edit the extra infos of a Project
Edit the location info of a Project
Edit objectives for a given Project
Edit the status of a Project
Edit themes for a given Project
Django Views for a Project Sheet
When one starts a project, after having selected a topic
Before starting a project, one needs to pick a topic
Display a page where it is possible to submit either a video or picture Only call when the project is not yet created, else it’s project_sheet_show with add_media=True that is called.
Add a picture to a project
Embed a video to a project
Given a language and a slug, create a translation for a new language
Delete a picture from a project sheet
Delete a video from a project sheet
Edit a translatable field of a project (such as baseline)
FIXME This view is used for both project creation and editing. Should be splitted.
Edit a question for a given project sheet translation
FIXME: Not sure if this is secure. Question may be assigned to projects that doesn’t link to them.
Edit references of a project
Edit themes (using tags) of a given project sheet. Non-Ajax version.
Show the history of a project member
Filter framework
Implements a filter on I4pProject best of
Filter base class
Implements custom multi select checkbox widget FIXME: find source, maybe djangosnippets.org
Simulates a full-text search in either the baseline or the title.
Implements a filter on I4pProject location
Implements a filter on I4pProject objective
Implements a filter on I4pProjectTranslation progression
Implements a filter on I4pProject status
Implements a filter on I4pProjectTranslation themes (tags)
Implements a filter on I4pProject topics
Toolkit for a project sheet management
Build the set of filter in order to include them in homepage and project list page
request : the GET variables passes to the view (i.e i4pbase.views.homepage or project_sheet.views.project_sheet_list)
Return : - the set of filters form - an extra context
Create a translation of a project.
Diff between two model fields
Create a project translation for the given language_code with the given slug.
This version does need a parent. Beware: using it twice for the same language with a different slug can lead to duplicate projects. When possible, use the “_from_parent” version instead.
Create a project translation for the given language_code, related to a parent project (language agnostic)
Return the diff as a dict of the given version queryset
Get a translation of a given project, looking at slugs in any language
Get a translation of a given project
Get a translation of a given project. If we have a fallback language, try to use it. If we also have fallback_any, then pick the first translation. Otherwise, raise a DoesNotExist exception
#-- encoding: utf-8 --
from django.conf.urls.defaults import patterns, url
from django.views.decorators.cache import cache_page
from django.views.generic.simple import direct_to_template
from . import views
from . import ajax
import feeds
PROJECT_AUTHORIZED_FIELDS = "|".join([
'title',
'baseline',
'about_section',
'partners_section',
'callto_section',
])
urlpatterns = patterns('',
url(r'^add/$', views.ProjectTopicSelectView.as_view(), name='project_sheet-start'),
url(r'^add/(?P<topic_slug>[-\w]+)/$', views.ProjectStartView.as_view(), name='project_sheet-start'),
url(r'^list/$', views.project_sheet_list, name='project_sheet-list'),
url(r'^recent-changes/$', views.ProjectRecentChangesView.as_view(), name='project_sheet-recent-changes'),
url(r'^edit/(?P<topic_slug>[-\w]+)/(?P<field>(%s))/$' % PROJECT_AUTHORIZED_FIELDS, views.project_sheet_edit_field, name='project_sheet-edit-field'),
url(r'^(?P<slug>[-\w]+)/edit/location/$', views.project_sheet_edit_location, name='project_sheet-instance-edit-location'),
url(r'^(?P<slug>[-\w]+)/edit/status/$', ajax.project_sheet_edit_status, name='project_sheet-instance-edit-status'),
url(r'^(?P<slug>[-\w]+)/edit/question/(?P<question_id>[\d]+)/$', views.project_sheet_edit_question, name='project_sheet-instance-edit-question'),
url(r'^(?P<slug>[-\w]+)/edit/(?P<field>(%s))/$' % PROJECT_AUTHORIZED_FIELDS, views.project_sheet_edit_field, name='project_sheet-instance-edit-field'),
url(r'^(?P<project_slug>[-\w]+)/edit/references/$', views.project_sheet_edit_references, name='project_sheet-instance-edit-references'),
url(r'^(?P<project_slug>[-\w]+)/translate/$', views.project_sheet_create_translation, name='project_sheet-translate'),
url(r'^(?P<project_slug>[-\w]+)/edit/related/$', views.project_sheet_edit_related, name='project_sheet-instance-edit-related'),
#AJAX
url(r'^(?P<project_slug>[-\w]+)/update/related/$', ajax.project_update_related, name='project_sheet-project_update_related'),
url(r'^(?P<project_slug>[-\w]+)/history/$', views.project_sheet_history, name='project_sheet-history'),
url(r'^(?P<slug>[-\w]+)/$', views.project_sheet_show, name='project_sheet-show'),
url(r'^(?P<slug>[-\w]+)/add/media/$', views.project_sheet_show, {'add_media' : True}, name='project_sheet-instance-add-media'),
url(r'^add/media/$', views.project_sheet_add_media, name='project_sheet-add-media'),
url(r'^add/picture/$', views.project_sheet_add_picture, name='project_sheet-add-picture'),
url(r'^(?P<slug>[-\w]+)/add/picture/$', views.project_sheet_add_picture, name='project_sheet-instance-add-picture'),
url(r'^add/video/$', views.project_sheet_add_video, name='project_sheet-add-video'),
url(r'^(?P<slug>[-\w]+)/add/video/$', views.project_sheet_add_video, name='project_sheet-instance-add-video'),
url(r'^(?P<slug>[-\w]+)/del/picture/(?P<pic_id>\d+)/$', views.project_sheet_del_picture, name='project_sheet-instance-del-picture'),
url(r'^(?P<slug>[-\w]+)/del/video/(?P<vid_id>\d+)/$', views.project_sheet_del_video, name='project_sheet-instance-del-video'),
url(r'^(?P<project_slug>[-\w]+)/member/delete/(?P<username>[-\w]+)/$', views.project_sheet_member_delete, name='project_sheet-instance-del-member'),
url(r'^(?P<project_slug>[-\w]+)/member/add/$', views.project_sheet_member_add, name='project_sheet-instance-add-member'),
# Ajax views
url(r'^start/ajax/field/save/$', ajax.project_textfield_save, name='project_sheet-ajax-field-save'),
url(r'^start/ajax/field/load/$', ajax.project_textfield_load, name='project_sheet-ajax-field-load'),
url(r'^(?P<project_slug>[-\w]+)/ajax/field/load/$', ajax.project_textfield_load, name='project_sheet-ajax-field-load'),
url(r'^(?P<project_slug>[-\w]+)/ajax/field/save/$', ajax.project_textfield_save, name='project_sheet-ajax-field-save'),
# RSS Feeds
url(r'^list/new-projects\.rss$', feeds.NewProjectsFeed(), name='project_sheet-new-projects-rss'),
url(r'^recent-changes\.rss$', feeds.LatestChangesFeed(), name='project_sheet-recent-changes-rss'),
)