2014-07-28 15:13:55 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from django import forms
|
2014-08-11 16:01:03 +02:00
|
|
|
from frontend.models import Project
|
2014-07-28 15:13:55 +02:00
|
|
|
from crispy_forms.helper import FormHelper
|
|
|
|
from crispy_forms.layout import Submit, Layout
|
|
|
|
|
2014-08-07 14:47:59 +02:00
|
|
|
class NewProjectForm(forms.ModelForm):
|
2014-07-28 15:13:55 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2014-08-07 14:47:59 +02:00
|
|
|
super(NewProjectForm, self).__init__(*args, **kwargs)
|
2014-07-28 15:13:55 +02:00
|
|
|
self.helper = FormHelper()
|
|
|
|
self.helper.form_class = 'form-horizontal'
|
|
|
|
self.helper.label_class = 'col-lg-2'
|
2014-07-29 14:48:09 +02:00
|
|
|
self.helper.field_class = 'col-lg-4'
|
2014-07-28 15:13:55 +02:00
|
|
|
self.helper.form_method = 'post'
|
|
|
|
self.helper.layout = Layout(
|
2014-07-29 14:48:09 +02:00
|
|
|
'name',
|
|
|
|
'description',
|
2014-08-07 14:47:59 +02:00
|
|
|
Submit('send', 'Create', css_class = 'btn-default')
|
2014-07-29 14:48:09 +02:00
|
|
|
)
|
2014-07-28 15:13:55 +02:00
|
|
|
|
2014-07-29 14:48:09 +02:00
|
|
|
name = forms.CharField(
|
|
|
|
label = "Name",
|
|
|
|
max_length = 255,
|
2014-07-28 15:13:55 +02:00
|
|
|
required = True,
|
|
|
|
)
|
|
|
|
|
2014-07-29 14:48:09 +02:00
|
|
|
description = forms.CharField(
|
|
|
|
label = "Description",
|
2014-07-28 15:13:55 +02:00
|
|
|
required = True,
|
|
|
|
)
|
|
|
|
|
2014-07-29 14:48:09 +02:00
|
|
|
class Meta:
|
2014-08-11 16:01:03 +02:00
|
|
|
model = Project
|
2014-07-29 14:48:09 +02:00
|
|
|
fields = ['name', 'description']
|
2014-08-11 16:01:03 +02:00
|
|
|
|
|
|
|
class FileUploadForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(FileUploadForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
self.helper.form_class = 'form-horizontal'
|
|
|
|
self.helper.label_class = 'col-lg-2'
|
|
|
|
self.helper.field_class = 'col-lg-4'
|
|
|
|
self.helper.form_method = 'post'
|
|
|
|
self.helper.layout = Layout(
|
|
|
|
'file',
|
|
|
|
Submit('send', 'Upload', css_class = 'btn-default')
|
|
|
|
)
|
|
|
|
|
|
|
|
file = forms.FileField()
|