Files
mayan-edms/mayan/apps/common/forms.py
Roberto Rosario ce3cf144d5 Merge branch 'master' into feature/merge_master
Conflicts:
	docs/releases/index.rst
	mayan/__init__.py
	mayan/apps/acls/south_migrations/0001_initial.py
	mayan/apps/acls/south_migrations/0002_auto__del_field_creatorsingleton_lock_id.py
	mayan/apps/checkouts/south_migrations/0001_initial.py
	mayan/apps/checkouts/south_migrations/0002_auto__add_field_documentcheckout_user_content_type__add_field_document.py
	mayan/apps/checkouts/south_migrations/0003_auto__chg_field_documentcheckout_checkout_datetime.py
	mayan/apps/checkouts/urls.py
	mayan/apps/common/forms.py
	mayan/apps/common/locale/ar/LC_MESSAGES/django.po
	mayan/apps/common/locale/bg/LC_MESSAGES/django.po
	mayan/apps/common/locale/bs_BA/LC_MESSAGES/django.po
	mayan/apps/common/locale/da/LC_MESSAGES/django.po
	mayan/apps/common/locale/de_CH/LC_MESSAGES/django.po
	mayan/apps/common/locale/de_DE/LC_MESSAGES/django.po
	mayan/apps/common/locale/en/LC_MESSAGES/django.po
	mayan/apps/common/locale/es/LC_MESSAGES/django.po
	mayan/apps/common/locale/fa/LC_MESSAGES/django.po
	mayan/apps/common/locale/fr/LC_MESSAGES/django.po
	mayan/apps/common/locale/hr_HR/LC_MESSAGES/django.po
	mayan/apps/common/locale/hu/LC_MESSAGES/django.po
	mayan/apps/common/locale/id/LC_MESSAGES/django.po
	mayan/apps/common/locale/it/LC_MESSAGES/django.po
	mayan/apps/common/locale/lv/LC_MESSAGES/django.po
	mayan/apps/common/locale/nb/LC_MESSAGES/django.po
	mayan/apps/common/locale/nl_NL/LC_MESSAGES/django.po
	mayan/apps/common/locale/pl/LC_MESSAGES/django.po
	mayan/apps/common/locale/pt/LC_MESSAGES/django.po
	mayan/apps/common/locale/pt_BR/LC_MESSAGES/django.po
	mayan/apps/common/locale/ro_RO/LC_MESSAGES/django.po
	mayan/apps/common/locale/ru/LC_MESSAGES/django.po
	mayan/apps/common/locale/sl_SI/LC_MESSAGES/django.po
	mayan/apps/common/locale/sq/LC_MESSAGES/django.po
	mayan/apps/common/locale/tr_TR/LC_MESSAGES/django.po
	mayan/apps/common/locale/vi_VN/LC_MESSAGES/django.po
	mayan/apps/common/locale/zh_CN/LC_MESSAGES/django.po
	mayan/apps/common/locale/zh_TW/LC_MESSAGES/django.po
	mayan/apps/common/south_migrations/0001_initial.py
	mayan/apps/common/south_migrations/0002_auto__add_autoadminsingleton.py
	mayan/apps/common/south_migrations/0003_auto__del_field_autoadminsingleton_original_auto_admin_password__del_f.py
	mayan/apps/common/south_migrations/0004_auto__del_field_autoadminsingleton_auto_admin_password__del_field_auto.py
	mayan/apps/common/south_migrations/0005_auto__del_field_autoadminsingleton_lock_id__del_field_anonymoususersin.py
	mayan/apps/common/south_migrations/0006_auto__add_shareduploadedfile.py
	mayan/apps/common/south_migrations/0007_auto__add_field_shareduploadedfile_filename.py
	mayan/apps/common/south_migrations/0008_auto__add_field_shareduploadedfile_datatime.py
	mayan/apps/common/south_migrations/0009_auto__add_userlocaleprofile.py
	mayan/apps/common/south_migrations/0010_create_locale_profiles.py
	mayan/apps/common/urls.py
	mayan/apps/common/views.py
	mayan/apps/converter/models.py
	mayan/apps/document_comments/models.py
	mayan/apps/document_indexing/south_migrations/0004_auto__add_documentrenamecount.py
	mayan/apps/document_indexing/south_migrations/0005_auto__add_unique_index_name__add_unique_index_title.py
	mayan/apps/document_indexing/south_migrations/0007_auto__del_documentrenamecount.py
	mayan/apps/document_signatures/south_migrations/0001_initial.py
	mayan/apps/document_signatures/south_migrations/0002_move_signatures_to_new_app.py
	mayan/apps/document_signatures/south_migrations/0003_auto__add_field_documentversionsignature_has_embedded_signature.py
	mayan/apps/document_signatures/south_migrations/0004_embedded_signature_state_copy.py
	mayan/apps/document_signatures/south_migrations/0005_auto__del_field_documentversionsignature_signature_state.py
	mayan/apps/document_states/__init__.py
	mayan/apps/document_states/south_migrations/0001_initial.py
	mayan/apps/document_states/south_migrations/0002_auto__add_field_workflowtransition_workflow.py
	mayan/apps/document_states/south_migrations/0003_auto__add_unique_workflowtransition_workflow_origin_state_destination_.py
	mayan/apps/document_states/south_migrations/0004_auto__del_field_workflowinstancelogentry_document__del_field_workflowi.py
	mayan/apps/document_states/south_migrations/0005_auto__del_unique_workflowstate_label__add_unique_workflowstate_workflo.py
	mayan/apps/document_states/south_migrations/0006_auto__del_unique_workflowtransition_label__del_unique_workflowtransiti.py
	mayan/apps/document_states/south_migrations/0008_auto__add_field_workflowinstancelogentry_user__add_field_workflowinsta.py
	mayan/apps/document_states/south_migrations/0009_auto__add_index_workflowinstancelogentry_datetime.py
	mayan/apps/document_states/urls.py
	mayan/apps/documents/__init__.py
	mayan/apps/documents/links.py
	mayan/apps/documents/south_migrations/0001_initial.py
	mayan/apps/documents/south_migrations/0002_filename_extension_merge.py
	mayan/apps/documents/south_migrations/0003_auto__del_field_document_file_extension.py
	mayan/apps/documents/south_migrations/0004_auto__add_documentversion__add_unique_documentversion_document_mayor_m.py
	mayan/apps/documents/south_migrations/0005_document_versions.py
	mayan/apps/documents/south_migrations/0006_fix_invalid_document_version_id_keys.py
	mayan/apps/documents/south_migrations/0007_remove_old_file_fields.py
	mayan/apps/documents/south_migrations/0008_fix_mayor_field_name.py
	mayan/apps/documents/south_migrations/0009_add_comment_field.py
	mayan/apps/documents/south_migrations/0010_auto__chg_field_document_date_added.py
	mayan/apps/documents/south_migrations/0011_auto__add_field_documentversion_signature_state.py
	mayan/apps/documents/south_migrations/0012_auto__add_field_documentversion_signature_file.py
	mayan/apps/documents/south_migrations/0013_auto__del_field_documentversion_signature_file__del_field_documentvers.py
	mayan/apps/documents/south_migrations/0014_change_document_mimetype_encoding_null.py
	mayan/apps/documents/south_migrations/0015_auto__add_unique_documenttype_name.py
	mayan/apps/documents/south_migrations/0017_auto__chg_field_documentversion_mimetype.py
	mayan/apps/documents/south_migrations/0018_auto__chg_field_documentpage_page_label.py
	mayan/apps/documents/south_migrations/0019_auto__add_index_documentversion_timestamp.py
	mayan/apps/documents/south_migrations/0020_auto__chg_field_recentdocument_datetime_accessed__chg_field_documentve.py
	mayan/apps/documents/south_migrations/0021_auto__del_field_documentversion_serial__del_field_documentversion_rele.py
	mayan/apps/documents/south_migrations/0022_set_doc_type.py
	mayan/apps/documents/south_migrations/0023_auto__chg_field_document_document_type.py
	mayan/apps/documents/south_migrations/0024_auto__add_field_documenttype_ocr.py
	mayan/apps/documents/south_migrations/0025_auto__add_field_document_language.py
	mayan/apps/documents/south_migrations/0026_auto__add_field_document_label.py
	mayan/apps/documents/south_migrations/0027_move_filename_to_label.py
	mayan/apps/documents/south_migrations/0028_auto__del_field_documentversion_filename.py
	mayan/apps/documents/south_migrations/0029_auto__del_field_documentversion_major__del_field_documentversion_micro.py
	mayan/apps/documents/south_migrations/0030_auto__add_unique_documenttypefilename_document_type_filename.py
	mayan/apps/documents/south_migrations/0031_remove_orphan_documents.py
	mayan/apps/dynamic_search/south_migrations/0001_initial.py
	mayan/apps/dynamic_search/south_migrations/0002_auto__chg_field_recentsearch_datetime_created__add_index_recentsearch_.py
	mayan/apps/dynamic_search/templatetags/search_tags.py
	mayan/apps/events/south_migrations/0001_initial.py
	mayan/apps/events/south_migrations/0002_migrate_history_data.py
	mayan/apps/folders/models.py
	mayan/apps/folders/south_migrations/0001_initial.py
	mayan/apps/folders/south_migrations/0002_increase_title_size.py
	mayan/apps/folders/south_migrations/0004_m2m_fields.py
	mayan/apps/folders/south_migrations/0005_auto__del_folderdocument.py
	mayan/apps/folders/south_migrations/0006_auto__chg_field_folder_datetime_created.py
	mayan/apps/history/models.py
	mayan/apps/history/south_migrations/0001_initial.py
	mayan/apps/history/south_migrations/0002_auto__chg_field_history_datetime.py
	mayan/apps/history/south_migrations/0003_auto__del_history__del_historytype__del_unique_historytype_namespace_n.py
	mayan/apps/installation/__init__.py
	mayan/apps/installation/models.py
	mayan/apps/installation/south_migrations/0001_initial.py
	mayan/apps/installation/south_migrations/0002_auto__del_field_installation_lock_id.py
	mayan/apps/installation/south_migrations/0003_auto__del_field_installation_is_first_run.py
	mayan/apps/linking/south_migrations/0001_initial.py
	mayan/apps/linking/south_migrations/0003_auto__chg_field_smartlinkcondition_foreign_document_data.py
	mayan/apps/linking/urls.py
	mayan/apps/lock_manager/south_migrations/0001_initial.py
	mayan/apps/lock_manager/south_migrations/0002_auto__chg_field_lock_creation_datetime.py
	mayan/apps/mailer/models.py
	mayan/apps/main/locale/ar/LC_MESSAGES/django.po
	mayan/apps/main/locale/bg/LC_MESSAGES/django.po
	mayan/apps/main/locale/bs_BA/LC_MESSAGES/django.po
	mayan/apps/main/locale/da/LC_MESSAGES/django.po
	mayan/apps/main/locale/de_CH/LC_MESSAGES/django.po
	mayan/apps/main/locale/de_DE/LC_MESSAGES/django.po
	mayan/apps/main/locale/en/LC_MESSAGES/django.po
	mayan/apps/main/locale/es/LC_MESSAGES/django.po
	mayan/apps/main/locale/fa/LC_MESSAGES/django.po
	mayan/apps/main/locale/fr/LC_MESSAGES/django.po
	mayan/apps/main/locale/hr_HR/LC_MESSAGES/django.po
	mayan/apps/main/locale/hu/LC_MESSAGES/django.po
	mayan/apps/main/locale/id/LC_MESSAGES/django.po
	mayan/apps/main/locale/it/LC_MESSAGES/django.po
	mayan/apps/main/locale/lv/LC_MESSAGES/django.po
	mayan/apps/main/locale/nb/LC_MESSAGES/django.po
	mayan/apps/main/locale/nl_NL/LC_MESSAGES/django.po
	mayan/apps/main/locale/pl/LC_MESSAGES/django.po
	mayan/apps/main/locale/pt/LC_MESSAGES/django.po
	mayan/apps/main/locale/pt_BR/LC_MESSAGES/django.po
	mayan/apps/main/locale/ro_RO/LC_MESSAGES/django.po
	mayan/apps/main/locale/ru/LC_MESSAGES/django.po
	mayan/apps/main/locale/sl_SI/LC_MESSAGES/django.po
	mayan/apps/main/locale/sq/LC_MESSAGES/django.po
	mayan/apps/main/locale/tr_TR/LC_MESSAGES/django.po
	mayan/apps/main/locale/vi_VN/LC_MESSAGES/django.po
	mayan/apps/main/locale/zh_CN/LC_MESSAGES/django.po
	mayan/apps/main/locale/zh_TW/LC_MESSAGES/django.po
	mayan/apps/main/models.py
	mayan/apps/main/templates/main/about.html
	mayan/apps/main/templates/main/generic_list_horizontal_subtemplate.html
	mayan/apps/main/urls.py
	mayan/apps/metadata/south_migrations/0002_auto__add_unique_metadataset_title.py
	mayan/apps/metadata/south_migrations/0003_auto__chg_field_metadatatype_lookup.py
	mayan/apps/metadata/south_migrations/0005_auto__chg_field_documentmetadata_value.py
	mayan/apps/metadata/south_migrations/0007_auto__del_documenttypedefaults__del_documenttypemetadatatypeoptions__a.py
	mayan/apps/metadata/south_migrations/0008_auto__add_unique_documenttypemetadatatype_document_type_metadata_type.py
	mayan/apps/metadata/south_migrations/0009_auto__chg_field_metadatatype_title.py
	mayan/apps/metadata/south_migrations/0010_auto__add_unique_documentmetadata_document_metadata_type.py
	mayan/apps/metadata/south_migrations/0011_auto__add_field_metadatatype_validation.py
	mayan/apps/mimetype/models.py
	mayan/apps/navigation/classes.py
	mayan/apps/navigation/forms.py
	mayan/apps/navigation/models.py
	mayan/apps/ocr/api.py
	mayan/apps/ocr/south_migrations/0001_initial.py
	mayan/apps/ocr/south_migrations/0002_auto__del_field_documentqueue_state__del_field_queuedocument_delay__de.py
	mayan/apps/ocr/south_migrations/0003_auto__chg_field_queuedocument_node_name__chg_field_queuedocument_datet.py
	mayan/apps/ocr/south_migrations/0004_auto__del_documentqueue__del_queuedocument__add_documentversionocrerro.py
	mayan/apps/permissions/south_migrations/0001_initial.py
	mayan/apps/permissions/south_migrations/0002_auto__add_storedpermission__add_unique_storedpermission_namespace_name.py
	mayan/apps/permissions/south_migrations/0003_clear_permission_holders.py
	mayan/apps/permissions/south_migrations/0004_auto__del_permission__del_unique_permission_namespace_name.py
	mayan/apps/permissions/widgets.py
	mayan/apps/project_setup/__init__.py
	mayan/apps/project_setup/locale/ar/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/bg/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/bs_BA/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/da/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/de_CH/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/de_DE/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/en/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/es/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/fa/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/fr/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/hr_HR/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/hu/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/id/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/it/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/lv/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/nb/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/nl_NL/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/pl/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/pt/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/pt_BR/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/ro_RO/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/ru/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/sl_SI/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/sq/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/tr_TR/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/vi_VN/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/zh_CN/LC_MESSAGES/django.po
	mayan/apps/project_setup/locale/zh_TW/LC_MESSAGES/django.po
	mayan/apps/project_setup/models.py
	mayan/apps/project_setup/urls.py
	mayan/apps/project_tools/__init__.py
	mayan/apps/project_tools/locale/ar/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/bg/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/bs_BA/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/da/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/de_CH/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/de_DE/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/en/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/es/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/fa/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/fr/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/hr_HR/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/hu/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/id/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/it/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/lv/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/nb/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/nl_NL/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/pl/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/pt/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/pt_BR/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/ro_RO/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/ru/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/sl_SI/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/sq/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/tr_TR/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/vi_VN/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/zh_CN/LC_MESSAGES/django.po
	mayan/apps/project_tools/locale/zh_TW/LC_MESSAGES/django.po
	mayan/apps/project_tools/models.py
	mayan/apps/project_tools/urls.py
	mayan/apps/rest_api/models.py
	mayan/apps/smart_settings/models.py
	mayan/apps/sources/south_migrations/0001_initial.py
	mayan/apps/sources/south_migrations/0002_preview_width_required.py
	mayan/apps/sources/south_migrations/0003_auto__del_field_stagingfolder_icon__del_field_webform_icon.py
	mayan/apps/sources/south_migrations/0004_auto__del_stagingfolder__del_webform__del_watchfolder__del_outofproces.py
	mayan/apps/sources/south_migrations/0005_auto__add_imapemail__add_intervalbasemodel__add_pop3email__add_emailba.py
	mayan/apps/sources/south_migrations/0006_auto__del_field_source_whitelist__del_field_source_blacklist.py
	mayan/apps/sources/south_migrations/0007_set_doc_type.py
	mayan/apps/sources/south_migrations/0008_auto__chg_field_intervalbasemodel_document_type.py
	mayan/apps/sources/south_migrations/0009_auto__del_watchfoldersource__chg_field_intervalbasemodel_document_type.py
	mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py
	mayan/apps/sources/south_migrations/0011_auto__del_field_intervalbasemodel_document_type.py
	mayan/apps/sources/south_migrations/0012_auto__add_field_intervalbasemodel_document_type.py
	mayan/apps/sources/south_migrations/0013_auto__del_field_watchfoldersource_delete_after_upload.py
	mayan/apps/storage/models.py
	mayan/apps/tags/south_migrations/0001_initial.py
	mayan/apps/tags/south_migrations/0003_remove_taggit.py
	mayan/apps/tags/south_migrations/0005_auto__add_unique_tag_label.py
	mayan/apps/tags/south_migrations/0006_auto__del_tagproperties.py
	mayan/apps/user_management/models.py
	mayan/settings/base.py
	mayan/urls.py
	requirements/common.txt
2015-06-01 23:20:17 -04:00

162 lines
5.6 KiB
Python

from __future__ import unicode_literals
import warnings
import os
from django import forms
from django.conf import settings
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.db import models
from django.utils.html import escape
from django.utils.translation import ugettext_lazy as _
from .models import UserLocaleProfile
from .utils import return_attrib
from .widgets import DetailSelectMultiple, EmailInput, PlainWidget
class DetailForm(forms.ModelForm):
def __init__(self, extra_fields=None, *args, **kwargs):
super(DetailForm, self).__init__(*args, **kwargs)
if extra_fields:
for extra_field in extra_fields:
result = return_attrib(self.instance, extra_field['field'])
label = 'label' in extra_field and extra_field['label'] or None
# TODO: Add others result types <=> Field types
if isinstance(result, models.query.QuerySet):
self.fields[extra_field['field']] = \
forms.ModelMultipleChoiceField(
queryset=result, label=label)
else:
self.fields[extra_field['field']] = forms.CharField(
label=extra_field['label'],
initial=escape(
return_attrib(
self.instance,
extra_field['field'], None
)
),
widget=PlainWidget)
for field_name, field in self.fields.items():
if isinstance(field.widget, forms.widgets.SelectMultiple):
self.fields[field_name].widget = DetailSelectMultiple(
choices=field.widget.choices,
attrs=field.widget.attrs,
queryset=getattr(field, 'queryset', None),
)
self.fields[field_name].help_text = ''
elif isinstance(field.widget, forms.widgets.Select):
self.fields[field_name].widget = DetailSelectMultiple(
choices=field.widget.choices,
attrs=field.widget.attrs,
queryset=getattr(field, 'queryset', None),
)
self.fields[field_name].help_text = ''
for field_name, field in self.fields.items():
self.fields[field_name].widget.attrs.update({'readonly': 'readonly'})
class GenericConfirmForm(forms.Form):
def __init__(self, *args, **kwargs):
pass
class GenericAssignRemoveForm(forms.Form):
def __init__(self, *args, **kwargs):
left_list_qryset = kwargs.pop('left_list_qryset', None)
right_list_qryset = kwargs.pop('right_list_qryset', None)
left_filter = kwargs.pop('left_filter', None)
super(GenericAssignRemoveForm, self).__init__(*args, **kwargs)
if left_filter:
self.fields['left_list'].queryset = left_list_qryset.filter(
*left_filter)
else:
self.fields['left_list'].queryset = left_list_qryset
self.fields['right_list'].queryset = right_list_qryset
left_list = forms.ModelMultipleChoiceField(required=False, queryset=None)
right_list = forms.ModelMultipleChoiceField(required=False, queryset=None)
class FilterForm(forms.Form):
def __init__(self, list_filters, *args, **kwargs):
super(FilterForm, self).__init__(*args, **kwargs)
for list_filter in list_filters:
label = list_filter.get('title', list_filter['name'])
self.fields[list_filter['name']] = forms.ModelChoiceField(
queryset=list_filter['queryset'],
label=label[0].upper() + label[1:], required=False)
class ChoiceForm(forms.Form):
"""
Form to be used in side by side templates used to add or remove
items from a many to many field
"""
def __init__(self, *args, **kwargs):
choices = kwargs.pop('choices', [])
label = kwargs.pop('label', _('Selection'))
super(ChoiceForm, self).__init__(*args, **kwargs)
self.fields['selection'].choices = choices
self.fields['selection'].label = label
self.fields['selection'].widget.attrs.update({'size': 14, 'class': 'choice_form'})
selection = forms.MultipleChoiceField()
class UserForm_view(DetailForm):
"""
Form used to display an user's public details
"""
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'is_staff', 'is_superuser', 'last_login', 'date_joined', 'groups')
class UserForm(forms.ModelForm):
"""
Form used to edit an user's mininal fields by the user himself
"""
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email')
class LocaleProfileForm(forms.ModelForm):
class Meta:
model = UserLocaleProfile
fields = ('language', 'timezone')
class LocaleProfileForm_view(DetailForm):
class Meta:
model = UserLocaleProfile
fields = ('language', 'timezone')
class FileDisplayForm(forms.Form):
text = forms.CharField(
label='', # _('Text'),
widget=forms.widgets.Textarea(
attrs={'cols': 40, 'rows': 20, 'readonly': 'readonly'}
)
)
def __init__(self, *args, **kwargs):
super(FileDisplayForm, self).__init__(*args, **kwargs)
changelog_path = os.path.join(settings.BASE_DIR, os.sep.join(self.DIRECTORY), self.FILENAME)
fd = open(changelog_path)
self.fields['text'].initial = fd.read()
fd.close()
class LicenseForm(FileDisplayForm):
FILENAME = 'LICENSE'
DIRECTORY = []