forms.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. from django import forms
  2. from django.conf import settings
  3. from django.core.files import File
  4. from django.contrib.auth.forms import UserCreationForm
  5. from django_file_form.forms import UploadedFileField, FileFormMixin, CharField, MultipleUploadedFileField
  6. from django.contrib.auth.models import User
  7. from django.urls import reverse, reverse_lazy
  8. from django.forms import *
  9. from django.forms.widgets import HiddenInput
  10. from django.forms.models import inlineformset_factory
  11. # from django.views.generic.edit.FormMixin
  12. # from crispy_forms.layout.buttons import Submit, InputButton
  13. from crispy_forms.layout import Layout, Field, Fieldset, Div, Row, Column, HTML, ButtonHolder, Submit
  14. from crispy_forms.bootstrap import InlineField
  15. from crispy_forms.helper import FormHelper
  16. from captcha.fields import CaptchaField
  17. from tinymce.widgets import TinyMCE
  18. from newsletter.forms import *
  19. from newsletter.models import *
  20. from marktplatz.widgets import *
  21. from .models import *
  22. from .urls import *
  23. def extend_help_text( help_text, myList ):
  24. extended_text = help_text
  25. extended_text += " z.B. "
  26. for x in myList:
  27. extended_text += x[1] + ", "
  28. extended_text = extended_text[:-2]
  29. extended_text += "."
  30. return extended_text
  31. class GeneralFields(forms.Form):
  32. terms = forms.BooleanField(required=True, )
  33. def __init__(self, *args, **kwargs):
  34. super(GeneralFields, self).__init__(*args, **kwargs)
  35. drurl = reverse_lazy( 'pages-generic', kwargs= { 'page': 'DATENSCHUTZRICHTLINIE' } )
  36. tmurl = reverse_lazy( 'pages-generic', kwargs= { 'page': 'TEILNAHME' } )
  37. self.fields ['terms'].label = 'Ich akzeptiere die <a target="_blank" href="{}"> Datenschutzrichtlinie</a> sowie die <a target="_blank" href="{}"> Teilnahmebedingungen</a> und habe sie gelesen.'.format(drurl, tmurl)
  38. class textSearchForm(forms.Form):
  39. mywidget = forms.TextInput( attrs={'onfocus': "this.value=''", 'class' : "border-thin"} )
  40. searchText = forms.CharField ( label='', widget = mywidget, max_length = 2048, min_length=3, empty_value="Suche...", initial='Suche...' )
  41. def __init__(self, *args, **kwargs):
  42. super(textSearchForm, self).__init__(*args, **kwargs)
  43. self.helper = FormHelper()
  44. self.helper.form_tag = False
  45. self.helper.layout = Layout(
  46. Div(
  47. Div('searchText', css_class='col-sm-6 col-6'),
  48. Div(
  49. ButtonHolder(
  50. Submit('submit', 'Suche', css_class='border-thin mybtn')
  51. ),
  52. css_class='col-sm-6 col-6'),
  53. css_class='form-row row mab-search-bar'),
  54. )
  55. class searchAgentForm(forms.ModelForm):
  56. agent_layout = Layout()
  57. class Meta:
  58. model = SearchAgent
  59. fields = ('ort', 'email')
  60. def __init__(self,*args, **kwargs):
  61. super().__init__(*args, **kwargs)
  62. # self.fields['ort'].widget = CheckboxSelectMultiple( attrs= { 'style' : "min-height: 250px;"} )
  63. self.agent_layout = Layout(
  64. Fieldset(
  65. ('Suchagent einrichten'),
  66. # 'ort',
  67. Div(
  68. Div('ort', css_class='col-sm-6 col-6 checkbox-ort'),
  69. Div(
  70. HTML("""
  71. <button onclick=" ganz_wien()" class="btn btn-primary border-thin border-dark mybtn">Ganz Wien</button>
  72. <script>
  73. function ganz_wien(){
  74. $(".checkbox-ort .custom-control-label:contains('Wien')").each(function() {
  75. $this = $(this);
  76. var selector = "#" + $this.attr('for') ;
  77. $( selector ).prop('checked', true);
  78. });
  79. }
  80. </script>
  81. <br>
  82. """),
  83. # HTML("""
  84. # <div id="div_id_ort" class="form-group">
  85. # <label for="" class=" requiredField">Ort<span class="asteriskField">*</span> </label>
  86. # <div class="">
  87. # <div class="row">
  88. # <div class="col-sm-6 col-6 checkbox-ort">
  89. #
  90. # <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_1" value="1010" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_1">
  91. # Wien 1
  92. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_2" value="1020" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_2">
  93. # Wien 2
  94. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_3" value="1030" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_3">
  95. # Wien 3
  96. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_4" value="1040" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_4">
  97. # Wien 4
  98. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_5" value="1050" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_5">
  99. # Wien 5
  100. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_6" value="1060" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_6">
  101. # Wien 6
  102. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_7" value="1070" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_7">
  103. # Wien 7
  104. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_8" value="1080" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_8">
  105. # Wien 8
  106. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_9" value="1090" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_9">
  107. # Wien 9
  108. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_10" value="1100" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_10">
  109. # Wien 10
  110. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_11" value="1110" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_11">
  111. # Wien 11
  112. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_12" value="1120" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_12">
  113. # Wien 12
  114. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_13" value="1130" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_13">
  115. # Wien 13
  116. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_14" value="1140" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_14">
  117. # Wien 14
  118. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_15" value="1150" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_15">
  119. # Wien 15
  120. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_16" value="1160" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_16">
  121. # Wien 16
  122. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_17" value="1170" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_17">
  123. # Wien 17
  124. # </label> </div>
  125. # </div>
  126. # <div class="col-sm-6 col-6 checkbox-ort">
  127. #
  128. #
  129. # <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_18" value="1180" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_18">
  130. # Wien 18
  131. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_19" value="1190" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_19">
  132. # Wien 19
  133. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_20" value="1200" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_20">
  134. # Wien 20
  135. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_21" value="1210" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_21">
  136. # Wien 21
  137. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_22" value="1220" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_22">
  138. # Wien 22
  139. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_23" value="1230" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_23">
  140. # Wien 23
  141. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_24" value="GERM" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_24">
  142. # Deutschland
  143. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_25" value="SCHW" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_25">
  144. # Schweiz
  145. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_26" value="VORA" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_26">
  146. # Vorarlberg
  147. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_27" value="TIRO" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_27">
  148. # Tirol
  149. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_28" value="SALZ" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_28">
  150. # Salzburg
  151. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_29" value="KAER" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_29">
  152. # Kärnten
  153. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_30" value="STEI" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_30">
  154. # Steiermark
  155. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_31" value="OBER" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_31">
  156. # Oberösterreich
  157. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_32" value="NIER" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_32">
  158. # Niederösterreich
  159. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_33" value="BURG" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_33">
  160. # Burgenland
  161. # </label> </div> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" name="ort" id="id_ort_34" value="WELT" style="min-height: 250px;"> <label class="custom-control-label" for="id_ort_34">
  162. # Welt
  163. # </label> </div>
  164. # </div>
  165. # </div>
  166. # <small id="hint_id_ort" class="form-text text-muted">Ort des Projektes</small>
  167. # </div>
  168. # </div>
  169. #
  170. # """),
  171. css_class='col-sm-6 col-6'),
  172. css_class='form-row row'),
  173. ),
  174. )
  175. class AgentNewslwtterForm( searchAgentForm, GeneralFields):
  176. email_field = forms.EmailField( label = 'Email', help_text="Du kannst den Suchagenten und den Newsletter jederzeit abbestellen - über einen Link in den Mails.", required=True, max_length=254 )
  177. subscribe = forms.BooleanField( label = 'Newsletter abonnieren', help_text='', required = False )
  178. captcha = CaptchaField( label = 'Bitte lösen Sie die Gleichung', generator='captcha.helpers.math_challenge' )
  179. def __init__(self, *args, **kwargs):
  180. # super(searchAgentForm, self).__init__(*args, **kwargs)
  181. super(AgentNewslwtterForm, self).__init__(*args, **kwargs)
  182. self.helper = FormHelper(self)
  183. self.helper.attrs = { 'enctype' : "multipart/form-data" }
  184. self.helper.form_action = reverse('agent-newsletter-create', kwargs={'newsletter_slug': "gemeinschaffen-newsletter"} )
  185. self.helper.layout = Layout(
  186. self.agent_layout,
  187. 'email_field',
  188. 'subscribe',
  189. 'terms',
  190. 'captcha',
  191. ButtonHolder(
  192. Submit('submit', 'Suchagent aktivieren', css_class='border-thin border-dark mybtn')
  193. ),
  194. )
  195. class NewsletterForm(SubscribeRequestForm, GeneralFields):
  196. class Meta:
  197. model = SubscribeRequestForm.Meta.model
  198. fields = SubscribeRequestForm.Meta.fields + (
  199. 'terms', )
  200. def __init__(self,*args, **kwargs):
  201. super(SubscribeRequestForm, self).__init__(*args, **kwargs)
  202. self.helper = FormHelper()
  203. self.helper.form_tag = False
  204. self.layout = Layout(
  205. Fieldset(
  206. ('Anmelden'),
  207. 'name_field',
  208. 'email_field',
  209. 'terms',
  210. Div(
  211. ButtonHolder(
  212. Submit('submit', 'Anmelden', css_class='border-thin mybtn')
  213. ),
  214. ),
  215. Div(HTML("&nbsp;") ),
  216. ),
  217. )
  218. self.helper.layout = self.layout
  219. class RegisterForm(forms.ModelForm, GeneralFields):
  220. class Meta:
  221. model = Contact
  222. fields = ('first_name','last_name','email','adress','postcode','city','country',
  223. 'phonenumber','alternate_phonenumber','skype_name','website', 'terms')
  224. class SignUpForm(UserCreationForm):
  225. captcha = CaptchaField( generator='captcha.helpers.math_challenge' )
  226. class Meta:
  227. model = User
  228. fields = ('username', 'password1', 'password2')
  229. class ProductForm(forms.ModelForm, GeneralFields):
  230. # terms = forms.BooleanField(required=True, label= ('Ich habe die Teilnahmebedingungen gelesen und akzeptiert.'))
  231. class Meta:
  232. model = Product
  233. fields = ( 'terms', 'name','claim','beschreibung','learning','gruendungsjahr','betriebgenommen','status',
  234. 'adresse', 'adresse_zusatz', 'plz', 'website','email','frei','kfrei','ort','rechtsform','orga','mitmachen',
  235. 'edit','public','type', )
  236. def __init__(self,*args, **kwargs):
  237. super(ProductForm, self).__init__(*args, **kwargs)
  238. self.fields['orga'].widget = ListTextWidget(data_list=Product.ORGANIZATION, name='orga_list')
  239. self.fields['rechtsform'].widget = ListTextWidget(data_list=Product.RECHTSFORM, name='rechtsform_list')
  240. self.fields['beschreibung'].widget = TinyMCE(attrs={'cols': 80, 'rows': 30})
  241. self.fields['learning'].widget = TinyMCE(attrs={'cols': 80, 'rows': 30})
  242. self.fields['edit'].widget = HiddenInput()
  243. self.fields['public'].widget = HiddenInput()
  244. self.fields['type'].widget = HiddenInput()
  245. self.fields['type'].initial = 'BASE'
  246. #
  247. # extend_help_text
  248. #
  249. self.fields['orga'].help_text = extend_help_text (self.fields['orga'].help_text, Product.ORGANIZATION)
  250. self.fields['rechtsform'].help_text = extend_help_text (self.fields['rechtsform'].help_text, Product.RECHTSFORM)
  251. self.helper = FormHelper()
  252. self.helper.form_tag = False
  253. self.product_layout = Layout(
  254. Fieldset(
  255. ('Über dein Projekt'),
  256. 'name','claim','beschreibung',
  257. Div(
  258. Div('frei', css_class='col-sm-6 col-6 '),
  259. Div('kfrei', css_class='col-sm-6 col-6 ' ),
  260. css_class='form-row row mab-field-highlight'),
  261. 'learning','status',
  262. Div(
  263. Div('adresse', css_class='col-sm-6 col-6'),
  264. Div('adresse_zusatz', css_class='col-sm-6 col-6'),
  265. css_class='form-row row'),
  266. Div(
  267. Div('plz', css_class='col-sm-6 col-6'),
  268. Div('ort', css_class='col-sm-6 col-6'),
  269. css_class='form-row row'),
  270. 'rechtsform','orga',
  271. Div(
  272. Div('website', css_class='col-sm-6 col-6'),
  273. Div('email', css_class='col-sm-6 col-6'),
  274. css_class='form-row row'),
  275. Div(
  276. Div('gruendungsjahr', css_class='col-sm-6 col-6'),
  277. Div('betriebgenommen', css_class='col-sm-6 col-6'),
  278. css_class='form-row row'),
  279. 'edit','public', 'mitmachen', 'type',
  280. ),
  281. )
  282. self.helper.layout = self.product_layout
  283. class MobilitaetsForm(ProductForm):
  284. class Meta():
  285. model = MobilitaetsProjekt
  286. fields = ProductForm.Meta.fields + ( )
  287. def __init__(self,*args, **kwargs):
  288. super(MobilitaetsForm, self).__init__(*args, **kwargs)
  289. self.fields['type'].initial = 'MOBI'
  290. class ErnaehrungsForm(ProductForm):
  291. class Meta():
  292. model = ErnaehrungsProjekt
  293. fields = ProductForm.Meta.fields + ( )
  294. def __init__(self,*args, **kwargs):
  295. super(ErnaehrungsForm, self).__init__(*args, **kwargs)
  296. self.fields['type'].initial = 'ERNA'
  297. class EnergyForm(ProductForm):
  298. class Meta():
  299. model = EnergyProjekt
  300. fields = ProductForm.Meta.fields + ( )
  301. def __init__(self,*args, **kwargs):
  302. super(EnergyForm, self).__init__(*args, **kwargs)
  303. self.fields['type'].initial = 'ENER'
  304. class WohnprojektForm(ProductForm):
  305. class Meta:
  306. model = Wohnprojekt
  307. fields = ProductForm.Meta.fields + (
  308. 'eigentum', 'inseratstext', 'altneu', 'schwerpunkt', 'wohnbaufoerderung', 'artmodell', 'bautraeger', 'architektur', 'aerwachsene', 'akinder', 'awohnungen', 'wohnflaeche', 'gewerbeflaechen', 'gemeinschaftsflaeche', 'sonstige_flaechen', 'flaeche', 'kflaechen', 'gemeinschaftr', 'kgemeinschaftr', 'gewerbe', 'sonderwohnformen', 'raumangebot', 'kraumangebot', 'parbeiten', 'karbeiten', 'bauweise', 'zielgruppen', 'gprojekte', 'oekologie', 'freiraumangebote', 'gaestwohnungen', 'urbanem',
  309. )
  310. def __init__(self,*args, **kwargs):
  311. super(WohnprojektForm, self).__init__(*args, **kwargs)
  312. #
  313. #
  314. self.fields['artmodell'].widget = ListTextWidget(data_list=Wohnprojekt.ARTMODELL, name='artmodell_list')
  315. self.fields['bautraeger'].widget = ListTextWidget(data_list=Wohnprojekt.BAUTRAEGER, name='bautraeger_list')
  316. self.fields['bauweise'].widget = ListTextWidget(data_list=Wohnprojekt.BAUWEISE, name='bauweise_list')
  317. self.fields['zielgruppen'].widget = ListTextWidget(data_list=Wohnprojekt.ZIELGRUPPEN, name='zielgruppen_list')
  318. self.fields['gprojekte'].widget = ListTextWidget(data_list=Wohnprojekt.GPROJEKTE, name='gprojekte_list')
  319. self.fields['freiraumangebote'].widget = ListTextWidget(data_list=Wohnprojekt.FREIANGEBOT, name='freiraumangebote_list')
  320. self.fields['gewerbe'].widget = ListTextWidget(data_list=Wohnprojekt.GEWERBE, name='gewerbe_list')
  321. #
  322. #
  323. self.fields['bauweise'].help_text = extend_help_text (self.fields['bauweise'].help_text, Wohnprojekt.BAUWEISE)
  324. self.fields['zielgruppen'].help_text = extend_help_text (self.fields['zielgruppen'].help_text, Wohnprojekt.ZIELGRUPPEN)
  325. self.fields['gprojekte'].help_text = extend_help_text (self.fields['gprojekte'].help_text, Wohnprojekt.GPROJEKTE)
  326. #
  327. #
  328. self.fields['frei'].label = "Wohnung Frei"
  329. self.fields['inseratstext'].label = "Inseratstext für Raumangebote"
  330. #
  331. #
  332. self.fields['type'].initial = 'WOHN'
  333. self.helper = FormHelper()
  334. self.helper.form_tag = False
  335. self.helper.layout = Layout(
  336. self.product_layout,
  337. Fieldset( 'Wohnprojekt',
  338. 'eigentum',
  339. 'artmodell',
  340. 'altneu',
  341. 'schwerpunkt',
  342. 'wohnbaufoerderung',
  343. 'bautraeger',
  344. 'architektur',
  345. Div(
  346. Div('aerwachsene', css_class='col-sm-6 col-6'),
  347. Div('akinder', css_class='col-sm-6 col-6'),
  348. css_class='form-row row'),
  349. 'awohnungen',
  350. 'gaestwohnungen',
  351. Fieldset ( 'Flächen',
  352. Div(
  353. Div('wohnflaeche', css_class='col-sm-3 col-3'),
  354. Div('gewerbeflaechen', css_class='col-sm-3 col-3'),
  355. Div('gemeinschaftsflaeche', css_class='col-sm-3 col-3'),
  356. Div('sonstige_flaechen', css_class='col-sm-3 col-3'),
  357. css_class='form-row row'),
  358. 'flaeche',
  359. 'kflaechen',
  360. ),
  361. Div(
  362. Div('gemeinschaftr', css_class='col-sm-6 col-6'),
  363. Div('raumangebot', css_class='col-sm-6 col-6'),
  364. Div('kgemeinschaftr', css_class='col-sm-6 col-6'),
  365. Div('kraumangebot', css_class='col-sm-6 col-6'),
  366. css_class='form-row row'),
  367. 'gewerbe',
  368. Div('inseratstext', css_class = "mab-field-highlight"),
  369. 'sonderwohnformen',
  370. Div(
  371. Div('parbeiten', css_class='col-sm-6 col-6'),
  372. Div('karbeiten', css_class='col-sm-6 col-6'),
  373. css_class='form-row row'),
  374. 'bauweise', 'zielgruppen', 'gprojekte', 'oekologie', 'freiraumangebote', 'urbanem',
  375. )
  376. )
  377. class MediaForm(FileFormMixin, forms.Form):
  378. image = UploadedFileField()
  379. name_for = forms.CharField()
  380. copyright = forms.CharField()
  381. #prefix = 'upload'
  382. def __init__(self, *args, **kwargs):
  383. super(MediaForm, self).__init__(*args, **kwargs)
  384. self.helper = FormHelper()
  385. self.helper.form_tag = False
  386. self.fields['name_for'].label = 'Bildbeschriftung'
  387. self.fields['copyright'].label = 'Urheberrechte'
  388. self.fields['image'].label = 'Bild oder Video'
  389. self.fields['image'].help_text = 'Bitte laden Sie Bilder im PNG- oder JPEG-Format hoch. Laden Sie Videos im MP4-Format hoch.'
  390. self.layout = Layout(
  391. Fieldset(
  392. (''),
  393. Div(
  394. Div('name_for', css_class='form-group col-md-6 mb-0'),
  395. Div('copyright', css_class='form-group col-md-4 mb-0')
  396. , css_class='form-row'),
  397. Div(
  398. Div('image', css_class='form-group col-md-6 mb-0'),
  399. css_class='form-row'),
  400. ))