|
|
@@ -202,10 +202,12 @@ class SignUpForm(UserCreationForm):
|
|
|
model = User
|
|
|
fields = ('username', 'password1', 'password2')
|
|
|
|
|
|
-class ProductForm(forms.ModelForm, GeneralFields):
|
|
|
+#
|
|
|
+# CREATE
|
|
|
+#
|
|
|
|
|
|
- # terms = forms.BooleanField(required=True, label= ('Ich habe die Teilnahmebedingungen gelesen und akzeptiert.'))
|
|
|
|
|
|
+class ProductForm(forms.ModelForm, GeneralFields):
|
|
|
|
|
|
class Meta:
|
|
|
model = Product
|
|
|
@@ -215,7 +217,7 @@ class ProductForm(forms.ModelForm, GeneralFields):
|
|
|
'edit','public','type', )
|
|
|
|
|
|
|
|
|
- def __init__(self,*args, **kwargs):
|
|
|
+ def __init__(self, *args, **kwargs):
|
|
|
super(ProductForm, self).__init__(*args, **kwargs)
|
|
|
|
|
|
self.fields['orga'].widget = ListTextWidget(data_list=Product.ORGANIZATION, name='orga_list')
|
|
|
@@ -232,6 +234,18 @@ class ProductForm(forms.ModelForm, GeneralFields):
|
|
|
self.fields['orga'].help_text = extend_help_text (self.fields['orga'].help_text, Product.ORGANIZATION)
|
|
|
self.fields['rechtsform'].help_text = extend_help_text (self.fields['rechtsform'].help_text, Product.RECHTSFORM)
|
|
|
|
|
|
+
|
|
|
+ #
|
|
|
+ # FORM HELPER
|
|
|
+ #
|
|
|
+
|
|
|
+ if 'instance' in kwargs:
|
|
|
+ self.redirect_to_pics = reverse_lazy( 'projekt-bearbeiten-submit-pics', kwargs= { 'type': self.Meta.type } )
|
|
|
+ self.redirect_to_publish = reverse_lazy( 'projekt-bearbeiten-publish', kwargs= { 'type': self.Meta.type } )
|
|
|
+ else:
|
|
|
+ self.redirect_to_pics = reverse_lazy( 'neues-projekt-submit-pics', kwargs = { 'type': self.Meta.type } )
|
|
|
+ self.redirect_to_publish = reverse_lazy( 'neues-projekt-publish', kwargs = { 'type': self.Meta.type } )
|
|
|
+
|
|
|
self.helper = FormHelper( )
|
|
|
self.helper.attrs = {'id': 'upload_mab', 'enctype': 'multipart/form-dat' }
|
|
|
# self.helper.form_tag = True
|
|
|
@@ -270,29 +284,26 @@ class ProductForm(forms.ModelForm, GeneralFields):
|
|
|
self.submit_layout = Layout(
|
|
|
'terms',
|
|
|
|
|
|
-
|
|
|
-
|
|
|
HTML("<br>"),
|
|
|
|
|
|
Div(
|
|
|
Div(
|
|
|
ButtonHolder(
|
|
|
Submit('submit', 'Speichern',
|
|
|
- onclick='this.form.action="./";',
|
|
|
css_class='border-thin mybtn')
|
|
|
),
|
|
|
css_class='col-sm-4 col-4'),
|
|
|
Div(
|
|
|
ButtonHolder(
|
|
|
Submit('submit', 'Speichern & Bilder hochladen',
|
|
|
- onclick='this.form.action="{}";'.format( reverse_lazy( 'neues-projekt-submit-pics', kwargs= { 'type': self.Meta.type } ) ),
|
|
|
+ onclick='this.form.action="{}";'.format( self.redirect_to_pics ),
|
|
|
css_class='border-thin mybtn')
|
|
|
),
|
|
|
css_class='col-sm-4 col-4'),
|
|
|
Div(
|
|
|
ButtonHolder(
|
|
|
Submit('submit', 'Speichern und Freischaltung Anfragen',
|
|
|
- onclick='this.form.action="{}";'.format( reverse_lazy( 'neues-projekt-publish', kwargs= { 'type': self.Meta.type } ) ),
|
|
|
+ onclick='this.form.action="{}";'.format( self.redirect_to_publish ),
|
|
|
css_class='border-thin mybtn'
|
|
|
),
|
|
|
HTML("<br><p>Dein Projekt ist noch nicht für jede Person sichtbar, damit wir dein Projekt freischalten, klicke auf diesen Button.</p>")
|
|
|
@@ -429,6 +440,11 @@ class WohnprojektForm(ProductForm):
|
|
|
self.submit_layout,
|
|
|
)
|
|
|
|
|
|
+#
|
|
|
+# UPDATE
|
|
|
+#
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|