| author | ymh <ymh.work@gmail.com> |
| Wed, 15 Sep 2010 15:07:08 +0200 | |
| changeset 60 | a8ad7ebf5902 |
| parent 44 | b7e3f3b2d150 |
| child 62 | 39b2dab4f939 |
| permissions | -rw-r--r-- |
| 0 | 1 |
from django import forms |
2 |
from models import Project, Content |
|
3 |
import uuid |
|
| 41 | 4 |
from utils import generate_uuid |
5 |
from django.forms.widgets import Widget |
|
6 |
from django.contrib.admin import widgets as admin_widgets |
|
7 |
from django.core.urlresolvers import reverse |
|
8 |
from ldt.settings import BASE_URL |
|
| 44 | 9 |
from ldt.forms import widgets as ldt_widgets |
| 0 | 10 |
|
11 |
class LdtImportForm(forms.Form): |
|
12 |
importFile = forms.FileField() |
|
13 |
videoPath = forms.CharField(required=False) |
|
14 |
flatten = forms.BooleanField(required=False, initial=True) |
|
15 |
||
16 |
class LdtAddForm(forms.ModelForm): |
|
17 |
title = forms.CharField() |
|
18 |
# contents = forms.ModelMultipleChoiceField(Content.objects.all()) |
|
19 |
# owner = forms.ModelChoiceField(Author.objects.all()) |
|
20 |
class Meta: |
|
21 |
model = Project |
|
22 |
exclude = ("ldt_id", "ldt", "created_by", "changed_by", "creation_date", "modification_date", "state", "owner") |
|
23 |
||
24 |
class ReindexForm(forms.Form): |
|
25 |
contents = forms.ModelMultipleChoiceField(Content.objects.all()) |
|
26 |
||
27 |
class SearchForm(forms.Form): |
|
28 |
search = forms.CharField() |
|
29 |
field = forms.ChoiceField([(u"all", u"all"), (u"title", u"title"), (u"abstract", u"resume"), (u"tags", u"tags")]) |
|
30 |
||
31 |
class AddProjectForm (forms.Form): |
|
32 |
title = forms.CharField() |
|
33 |
||
34 |
class CopyProjectForm (forms.Form): |
|
35 |
title = forms.CharField() |
|
| 41 | 36 |
|
37 |
||
38 |
class ContentForm(forms.ModelForm): |
|
39 |
||
40 |
#iri_id = forms.CharField(max_length=1024, widget=forms.HiddenInput, initial=generate_uuid) |
|
41 |
iriurl = forms.CharField(max_length=1024, widget=forms.HiddenInput, required=False) |
|
| 44 | 42 |
content_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False) |
| 41 | 43 |
|
44 |
def clean_iri_id(self): |
|
45 |
data = self.cleaned_data.get('iri_id') |
|
46 |
if not data: |
|
47 |
data = generate_uuid() |
|
48 |
return data |
|
49 |
||
50 |
def clean(self): |
|
51 |
cleaned_data = self.cleaned_data |
|
52 |
iriurl_data = cleaned_data.get('iriurl') |
|
53 |
iri_id_data = cleaned_data['iri_id'] |
|
54 |
if not iriurl_data: |
|
55 |
iriurl_data = "%s/%s.iri" % (iri_id_data, iri_id_data) |
|
56 |
cleaned_data['iriurl'] = iriurl_data |
|
57 |
return cleaned_data |
|
58 |
||
59 |
class Meta: |
|
60 |
model = Content |
|
61 |
exclude = ("creation_date", "update_date", "authors") |
|
62 |
widgets = { |
|
63 |
'iri_id': forms.HiddenInput, |
|
64 |
} |
|
65 |
||
66 |
class Media: |
|
67 |
css = { |
|
68 |
'all' : ('admin/css/forms.css','admin/css/base.css', 'admin/css/base.css', 'admin/css/widgets.css') |
|
69 |
} |
|
|
60
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
70 |
|
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
71 |
class MediaForm(forms.ModelForm): |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
72 |
|
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
73 |
media_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False) |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
74 |
|
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
75 |
class Meta: |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
76 |
model = Content |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
77 |
exclude = ("creation_date", "update_date", "creator") |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
78 |
|
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
79 |
class Media: |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
80 |
css = { |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
81 |
'all' : ('admin/css/forms.css','admin/css/base.css', 'admin/css/base.css', 'admin/css/widgets.css') |
|
a8ad7ebf5902
various update and splitmedia from content
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
82 |
} |