| author | cavaliet |
| Wed, 25 Jan 2012 16:55:04 +0100 | |
| branch | siteconfig |
| changeset 447 | 91d87f958a16 |
| parent 404 | 4adc42ab55fd |
| permissions | -rw-r--r-- |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
1 |
from django import forms |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
2 |
from django.utils.translation import ugettext_lazy as _ |
| 271 | 3 |
from django.contrib.auth.models import Group |
|
447
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
4 |
from djblets.siteconfig.forms import SiteSettingsForm |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
5 |
from ldt.forms import widgets as ldt_widgets |
|
447
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
6 |
from ldt.ldt_utils.siteconfig import load_site_config |
| 269 | 7 |
from ldt.security.forms import ShareForm |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
8 |
from models import Project, Content, Media |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
9 |
from utils import generate_uuid |
|
447
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
10 |
import re |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
11 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
12 |
class LdtImportForm(forms.Form): |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
13 |
importFile = forms.FileField() |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
14 |
videoPath = forms.CharField(required=False) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
15 |
flatten = forms.BooleanField(required=False, initial=True) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
16 |
|
|
268
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
17 |
class LdtAddForm(ShareForm): |
| 225 | 18 |
title = forms.CharField(required=True) |
| 269 | 19 |
contents = forms.ModelMultipleChoiceField(Content.objects.all()) |
| 178 | 20 |
description = forms.CharField(widget=forms.Textarea, required=False) |
|
268
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
21 |
|
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
22 |
class Meta: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
23 |
model = Project |
| 269 | 24 |
exclude = ("ldt_id", "ldt", "created_by", "changed_by", "creation_date", "modification_date", "state", "owner") |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
25 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
26 |
class ReindexForm(forms.Form): |
| 269 | 27 |
contents = forms.ModelMultipleChoiceField(Content.objects.all()) |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
28 |
index_projects = forms.BooleanField(required=False, initial=False) |
|
340
5f919a978f50
Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents:
327
diff
changeset
|
29 |
|
|
5f919a978f50
Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents:
327
diff
changeset
|
30 |
class StatAnnotationForm(forms.Form): |
|
343
1b9b509013a7
Stats are recomputed without parsing extra xml file when projects are saved from ligne de temps.
verrierj
parents:
340
diff
changeset
|
31 |
projects = forms.ModelMultipleChoiceField(Project.objects.all()) |
|
340
5f919a978f50
Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents:
327
diff
changeset
|
32 |
choose_all = forms.BooleanField(required=False, initial=False) |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
33 |
|
| 279 | 34 |
class SearchForm(forms.Form): |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
35 |
search = forms.CharField(label=_("Search")) |
| 160 | 36 |
field = forms.ChoiceField([(u"all", _("all")), (u"title", _("title")), (u"abstract", _("resume")), (u"tags", _("tags"))], label=_("Fields")) |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
37 |
ldt_pres = forms.BooleanField(required=False, initial=True, label=_("Display the results in Lignes De Temps")) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
38 |
|
|
268
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
39 |
class AddProjectForm (ShareForm): |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
40 |
title = forms.CharField(widget=forms.TextInput(attrs={'class':'inputbox required'})) |
| 178 | 41 |
description = forms.CharField(widget=forms.Textarea, required=False) |
|
268
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
42 |
|
|
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
43 |
class Meta: |
|
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
44 |
model = Project |
|
c0c161736794
Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents:
267
diff
changeset
|
45 |
exclude = ("ldt_id", "ldt", "created_by", "changed_by", "creation_date", "modification_date", "state", "owner", "contents") |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
46 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
47 |
class CopyProjectForm (forms.Form): |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
48 |
title = forms.CharField() |
| 285 | 49 |
group = forms.IntegerField(required=False) |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
50 |
|
| 269 | 51 |
class ContentForm(ShareForm): |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
52 |
iriurl = forms.CharField(max_length=1024, widget=forms.HiddenInput, required=False) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
53 |
content_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False, label=_("content.content_creation_date")) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
54 |
media_input_type = forms.ChoiceField(required=False, label=_("content.media_input_type"), choices=(("upload", _("file_upload")), ("url", _("url")), ("link", _("existing_media")), ("create", _("create_media")), ("none", _("none_media")))) |
| 260 | 55 |
groups = forms.ModelMultipleChoiceField(Group.objects.all(), required=False) |
| 383 | 56 |
is_public = forms.BooleanField(required=False) |
| 404 | 57 |
front_project = forms.ModelChoiceField(queryset=Project.objects.none(), required=False, label=_("content.front_project")) |
| 266 | 58 |
|
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
59 |
def clean_iri_id(self): |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
60 |
data = self.cleaned_data.get('iri_id') |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
61 |
if not data: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
62 |
data = generate_uuid() |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
63 |
return data |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
64 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
65 |
def clean(self): |
| 269 | 66 |
super(ContentForm, self).clean() |
|
122
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
67 |
cleaned_data = self.cleaned_data |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
68 |
iriurl_data = cleaned_data.get('iriurl') |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
69 |
iri_id_data = cleaned_data['iri_id'] |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
70 |
if not iriurl_data: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
71 |
iriurl_data = "%s/%s.iri" % (iri_id_data, iri_id_data) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
72 |
cleaned_data['iriurl'] = iriurl_data |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
73 |
return cleaned_data |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
74 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
75 |
class Meta: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
76 |
model = Content |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
77 |
exclude = ("creation_date", "update_date", "authors") |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
78 |
widgets = { |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
79 |
'iri_id': forms.HiddenInput, |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
80 |
} |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
81 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
82 |
class Media: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
83 |
css = { |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
84 |
'all' : ('admin/css/forms.css', 'admin/css/base.css', 'admin/css/widgets.css') |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
85 |
} |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
86 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
87 |
class MediaForm(forms.ModelForm): |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
88 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
89 |
media_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
90 |
media_file = forms.FileField(required=False); |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
91 |
src = forms.CharField(required=False, max_length=1024) |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
92 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
93 |
class Meta: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
94 |
model = Media |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
95 |
exclude = ("creation_date", "update_date", "creator") |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
96 |
|
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
97 |
class Media: |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
98 |
css = { |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
99 |
'all' : ('admin/css/forms.css', 'admin/css/base.css', 'admin/css/widgets.css') |
|
f3a013f66974
Add search form, displaying the results in a regular LDT template. Update language files.
cavaliet
parents:
111
diff
changeset
|
100 |
} |
| 228 | 101 |
|
| 271 | 102 |
class GroupAddForm(ShareForm): |
| 228 | 103 |
name = forms.CharField(required=True) |
| 327 | 104 |
description = forms.CharField(widget=forms.Textarea, required=False) |
|
234
331f767d8996
Display error message when creating a group with an already existing name
verrierj
parents:
233
diff
changeset
|
105 |
|
|
331f767d8996
Display error message when creating a group with an already existing name
verrierj
parents:
233
diff
changeset
|
106 |
class Meta: |
|
331f767d8996
Display error message when creating a group with an already existing name
verrierj
parents:
233
diff
changeset
|
107 |
model = Group |
|
447
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
108 |
|
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
109 |
|
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
110 |
class GeneralSettingsForm(SiteSettingsForm): |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
111 |
my_array = forms.CharField( |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
112 |
label="Front tag list", |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
113 |
required=False, |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
114 |
help_text="A comma-separated list of tags !") |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
115 |
|
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
116 |
def load(self): |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
117 |
self.fields['my_array'].initial = ', '.join(self.siteconfig.get('front_tag_list')) |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
118 |
super(GeneralSettingsForm, self).load() |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
119 |
|
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
120 |
def save(self): |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
121 |
self.siteconfig.set('front_tag_list',[x.strip() for x in self.cleaned_data['my_array'].split(',')]) |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
122 |
super(GeneralSettingsForm, self).save() |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
123 |
load_site_config() |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
124 |
|
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
125 |
class Meta: |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
126 |
save_blacklist = ('my_array',) |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
127 |
title = "Front Settings : tag list, etc..." |
|
91d87f958a16
Update front tag list management with virtual SETTINGS and djblets.siteconfig.
cavaliet
parents:
404
diff
changeset
|
128 |