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