71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from django import forms
|
|
from frontend.models import Project, PersonGlobalIdentity
|
|
from crispy_forms.helper import FormHelper
|
|
from crispy_forms.layout import Submit, Layout
|
|
|
|
class NewProjectForm(forms.ModelForm):
|
|
def __init__(self, *args, **kwargs):
|
|
super(NewProjectForm, self).__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_class = u'form-horizontal'
|
|
self.helper.label_class = u'col-lg-2'
|
|
self.helper.field_class = u'col-lg-4'
|
|
self.helper.form_method = u'post'
|
|
self.helper.layout = Layout(
|
|
u'name',
|
|
u'description',
|
|
Submit(u'send', u'Create', css_class=u'btn-default')
|
|
)
|
|
|
|
name = forms.CharField(
|
|
label=u"Name",
|
|
max_length=255,
|
|
required=True,
|
|
)
|
|
|
|
description = forms.CharField(
|
|
label=u"Description",
|
|
required=True,
|
|
)
|
|
|
|
class Meta:
|
|
model = Project
|
|
fields = [u'name', u'description']
|
|
|
|
class FileUploadForm(forms.Form):
|
|
def __init__(self, *args, **kwargs):
|
|
super(FileUploadForm, self).__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_class = u'form-horizontal'
|
|
self.helper.label_class = u'col-lg-2'
|
|
self.helper.field_class = u'col-lg-4'
|
|
self.helper.form_method = u'post'
|
|
self.helper.layout = Layout(
|
|
u'file',
|
|
Submit(u'send', u'Upload', css_class=u'btn-default')
|
|
)
|
|
|
|
file = forms.FileField()
|
|
|
|
|
|
class PersonMapForm(forms.Form):
|
|
def __init__(self, *args, **kwargs):
|
|
super(PersonMapForm, self).__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_class = u'form-horizontal'
|
|
self.helper.label_class = u'col-lg-2'
|
|
self.helper.field_class = u'col-lg-4'
|
|
self.helper.form_method = u'post'
|
|
self.helper.layout = Layout(
|
|
u'action',
|
|
u'global_identity',
|
|
Submit(u'skip', u'Skip', css_class=u'btn-default'),
|
|
Submit(u'save-continue', u'Save and continue', css_class=u'btn-default'),
|
|
)
|
|
|
|
action = forms.ChoiceField(choices=[(u'new', u'Create new global Identity'), (u'existing', u'Map to existing identity')], initial=u'new', widget=forms.RadioSelect())
|
|
global_identity = forms.ModelChoiceField(queryset=PersonGlobalIdentity.objects.all(), required=False)
|
|
|