| author | ymh <ymh.work@gmail.com> |
| Sun, 01 May 2011 03:30:40 +0200 | |
| changeset 77 | 7923feb2e362 |
| parent 63 | 93325a5d61f0 |
| child 90 | 4ddb88f103ad |
| permissions | -rw-r--r-- |
| 0 | 1 |
from django import forms |
| 63 | 2 |
from django.utils.translation import ugettext_lazy as _ |
3 |
from ldt.forms import widgets as ldt_widgets |
|
| 0 | 4 |
from models import Project, Content, Media |
5 |
from utils import generate_uuid |
|
6 |
||
7 |
class LdtImportForm(forms.Form): |
|
8 |
importFile = forms.FileField() |
|
9 |
videoPath = forms.CharField(required=False) |
|
10 |
flatten = forms.BooleanField(required=False, initial=True) |
|
11 |
||
12 |
class LdtAddForm(forms.ModelForm): |
|
13 |
title = forms.CharField() |
|
| 77 | 14 |
contents = forms.ModelMultipleChoiceField(Content.objects.all()) |
| 0 | 15 |
# owner = forms.ModelChoiceField(Author.objects.all()) |
16 |
class Meta: |
|
17 |
model = Project |
|
18 |
exclude = ("ldt_id", "ldt", "created_by", "changed_by", "creation_date", "modification_date", "state", "owner") |
|
19 |
||
20 |
class ReindexForm(forms.Form): |
|
21 |
contents = forms.ModelMultipleChoiceField(Content.objects.all()) |
|
| 77 | 22 |
index_projects = forms.BooleanField(initial=False) |
| 0 | 23 |
|
24 |
class SearchForm(forms.Form): |
|
25 |
search = forms.CharField() |
|
26 |
field = forms.ChoiceField([(u"all", u"all"), (u"title", u"title"), (u"abstract", u"resume"), (u"tags", u"tags")]) |
|
27 |
||
28 |
class AddProjectForm (forms.Form): |
|
29 |
title = forms.CharField(widget=forms.TextInput(attrs={'class':'inputbox required'})) |
|
30 |
||
31 |
class CopyProjectForm (forms.Form): |
|
32 |
title = forms.CharField() |
|
33 |
||
34 |
||
35 |
class ContentForm(forms.ModelForm): |
|
36 |
||
37 |
#iri_id = forms.CharField(max_length=1024, widget=forms.HiddenInput, initial=generate_uuid) |
|
38 |
iriurl = forms.CharField(max_length=1024, widget=forms.HiddenInput, required=False) |
|
39 |
content_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False, label=_("content.content_creation_date")) |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
40 |
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")))) |
| 0 | 41 |
|
42 |
def clean_iri_id(self): |
|
43 |
data = self.cleaned_data.get('iri_id') |
|
44 |
if not data: |
|
45 |
data = generate_uuid() |
|
46 |
return data |
|
47 |
||
48 |
def clean(self): |
|
49 |
cleaned_data = self.cleaned_data |
|
50 |
iriurl_data = cleaned_data.get('iriurl') |
|
51 |
iri_id_data = cleaned_data['iri_id'] |
|
52 |
if not iriurl_data: |
|
53 |
iriurl_data = "%s/%s.iri" % (iri_id_data, iri_id_data) |
|
54 |
cleaned_data['iriurl'] = iriurl_data |
|
55 |
return cleaned_data |
|
56 |
||
57 |
class Meta: |
|
58 |
model = Content |
|
59 |
exclude = ("creation_date", "update_date", "authors") |
|
60 |
widgets = { |
|
61 |
'iri_id': forms.HiddenInput, |
|
62 |
} |
|
63 |
||
64 |
class Media: |
|
65 |
css = { |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
66 |
'all' : ('admin/css/forms.css', 'admin/css/base.css', 'admin/css/widgets.css') |
| 0 | 67 |
} |
68 |
||
69 |
class MediaForm(forms.ModelForm): |
|
70 |
||
71 |
media_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False) |
|
72 |
media_file = forms.FileField(required=False); |
|
73 |
src = forms.CharField(required=False, max_length=1024) |
|
74 |
||
75 |
class Meta: |
|
76 |
model = Media |
|
77 |
exclude = ("creation_date", "update_date", "creator") |
|
78 |
||
79 |
class Media: |
|
80 |
css = { |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
81 |
'all' : ('admin/css/forms.css', 'admin/css/base.css', 'admin/css/widgets.css') |
| 0 | 82 |
} |