Ver Fonte

detail view, search agent, model change tracker

Juan Carlos há 5 anos atrás
pai
commit
c04cfaea0c

+ 19 - 30
marktplatz/forms.py

@@ -35,6 +35,12 @@ class VoteForm(forms.Form):
 
     #initial can be specified with old value in db maybe
 
+class searchAgentForm(forms.ModelForm):
+
+    class Meta:
+        model = SearchAgent
+        fields = '__all__'
+        # fields = ('first_name','last_name','adress','postcode','city','country', 'email','phonenumber','alternate_phonenumber','skype_name','website', 'terms')
 
 class RegisterForm(forms.ModelForm):
     terms = forms.BooleanField(required=True,  label= ('I accept and have read the <a href="https://www.mediaarchitecture.org/privacy-policy/">Privacy Policy.</a>'))
@@ -72,7 +78,7 @@ class SubmissionForm(forms.ModelForm):
         # 'title','country','city','year','owner','teaser_txt','header','category', 'description_txt',
          'terms',
         'name','claim','beschreibung','learning','gruendungsjahr','betriebgenommen','status','adresse','website','email','frei','kfrei', 'mitmachen','rechtsform','ort','orga',
-         'eigentum', 'inseratstext', 'altneu', 'schwerpunkt', 'artmodell', 'bautraeger', 'aerwachsene', 'akinder', 'awohnungen', 'wohnflaeche', 'gewerbeflaechen', 'gemeinschaftsflaeche', 'sonstige_flaechen', 'gemeinschaftr', 'sonderwohnformen', 'raumangebot', 'parbeiten', 'karbeiten', 'bauweise', 'zielgruppen', 'gprojekte', 'oekologie', 'freiraumangebote', 'gaestwohnungen',
+         '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',
          )
 
 
@@ -81,46 +87,29 @@ class SubmissionForm(forms.ModelForm):
 
        #
        #
-       #
-       #
-       self.fields['orga'].widget       = ListTextWidget(data_list=Product.ORGANIZATION,  name='orga_list')
-       self.fields['rechtsform'].widget = ListTextWidget(data_list=Product.RECHTSFORM,  name='rechtsform_list')
-       self.fields['artmodell'].widget = ListTextWidget(data_list=Wohnprojekt.ARTMODELL,  name='artmodell_list')
-       self.fields['bautraeger'].widget = ListTextWidget(data_list=Wohnprojekt.BAUTRAEGER,  name='bautraeger_list')
-       self.fields['bauweise'].widget = ListTextWidget(data_list=Wohnprojekt.BAUWEISE,  name='bauweise_list')
+       self.fields['orga'].widget        = ListTextWidget(data_list=Product.ORGANIZATION,  name='orga_list')
+       self.fields['rechtsform'].widget  = ListTextWidget(data_list=Product.RECHTSFORM,  name='rechtsform_list')
+       self.fields['artmodell'].widget   = ListTextWidget(data_list=Wohnprojekt.ARTMODELL,  name='artmodell_list')
+       self.fields['bautraeger'].widget  = ListTextWidget(data_list=Wohnprojekt.BAUTRAEGER,  name='bautraeger_list')
+       self.fields['bauweise'].widget    = ListTextWidget(data_list=Wohnprojekt.BAUWEISE,  name='bauweise_list')
        self.fields['zielgruppen'].widget = ListTextWidget(data_list=Wohnprojekt.ZIELGRUPPEN,  name='zielgruppen_list')
-
+       self.fields['gprojekte'].widget   = ListTextWidget(data_list=Wohnprojekt.GPROJEKTE,  name='gprojekte_list')
        #
        #
-       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)
-       self.fields['bauweise'].help_text = extend_help_text (self.fields['bauweise'].help_text, Wohnprojekt.BAUWEISE)
+       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)
+       self.fields['bauweise'].help_text    = extend_help_text (self.fields['bauweise'].help_text, Wohnprojekt.BAUWEISE)
        self.fields['zielgruppen'].help_text = extend_help_text (self.fields['zielgruppen'].help_text, Wohnprojekt.ZIELGRUPPEN)
+       self.fields['gprojekte'].help_text   = extend_help_text (self.fields['gprojekte'].help_text, Wohnprojekt.GPROJEKTE)
        #
        #
-       #
-       #
-
-       # self.fields['description_txt'].max_length = 2000
-       # self.fields['teaser_txt'].max_length = 750
 
        self.helper = FormHelper()
-       #self.helper.field_class = 'form_border'
        self.helper.form_tag = False
        self.helper.layout = Layout(
            Fieldset(
                ('Über dein Projekt'),
 
-               # Div(
-               #     Div('country', css_class='form-group col-md-6 mb-0'),
-               #     Div('city', css_class='form-group col-md-3 mb-0'),
-               #     Div('year', css_class='form-group col-md-3 mb-0'),
-               #     css_class='form-row row'),
-               # 'category',
-               # 'teaser_txt',
-               # 'description_txt',
-
-
                'name','claim','beschreibung','learning','status',
 
               Div(
@@ -146,7 +135,7 @@ class SubmissionForm(forms.ModelForm):
                   Div('betriebgenommen', css_class='col-sm-6 col-6'),
                   css_class='form-row  row'),
 
-             'eigentum', 'inseratstext', 'altneu', 'schwerpunkt', 'artmodell', 'bautraeger',
+             'eigentum', 'inseratstext', 'altneu', 'schwerpunkt', 'wohnbaufoerderung', 'artmodell', 'bautraeger',
 
               Div(
                   Div('aerwachsene',  css_class='col-sm-6 col-6'),
@@ -161,7 +150,7 @@ class SubmissionForm(forms.ModelForm):
                   Div('gemeinschaftsflaeche', css_class='col-sm-3 col-3'),
                   Div('sonstige_flaechen', css_class='col-sm-3 col-3'),
                   css_class='form-row  row'),
-             'gemeinschaftr', 'raumangebot', 'sonderwohnformen', 'parbeiten', 'karbeiten', 'bauweise', 'zielgruppen', 'gprojekte', 'oekologie', 'freiraumangebote', 'gaestwohnungen',
+             'kflaechen', 'gemeinschaftr', 'kgemeinschaftr', 'raumangebot', 'kraumangebot', 'sonderwohnformen', 'parbeiten', 'karbeiten', 'bauweise', 'zielgruppen', 'gprojekte', 'oekologie', 'freiraumangebote', 'gaestwohnungen',
 
            )
        )

+ 85 - 30
marktplatz/models.py

@@ -122,6 +122,28 @@ class Category(models.Model):
 
 class Product(models.Model):
 
+    # def save(self, update_fields=None, *args, **kwargs):
+    #     print(kwargs)
+    #     print(args)
+    #     print (update_fields)
+    #     # update_fields = ['frei']
+    #     super().save(*args, **kwargs)  # Call the "real" save() method.
+
+    #https://stackoverflow.com/questions/1355150/when-saving-how-can-you-check-if-a-field-has-changed
+    __original_frei = None
+
+    def __init__(self, *args, **kwargs):
+        super(Product, self).__init__(*args, **kwargs)
+        self.__original_frei = self.frei
+
+    def save(self, force_insert=False, force_update=False, *args, **kwargs):
+        if self.frei != self.__original_frei:
+            print('here we loop through search agents')
+            # name changed - do something here
+
+        super(Product, self).save(force_insert, force_update, *args, **kwargs)
+        self.__original_frei = self.frei
+
     STATUS = [
         ('ENT', 'Entwicklung'),
         ('BET', 'In Betrieb'),
@@ -206,9 +228,9 @@ class Product(models.Model):
     frei            = CharField   ( 'Platz frei', max_length = 4,    choices=FREI, default='NEIN', help_text="Gibt es freie Plätze?", null = True, blank=False )
     kfrei           = CharField   ( 'Platz frei - Kommentar',   max_length = 2048,  help_text="Kommentar", null = True, blank=True )
     rechtsform      = CharField   ( 'Rechtsform', max_length = 32, help_text="Rechtsform des Projektes", null = True, blank=True )
-    orga            = CharField   ( 'Organisationsform',  max_length = 64, help_text="Organisationsform des Projektes.", null = True, blank=True )
-    mitmachen  = BooleanField( 'Mitmachen möglich', default=False, help_text="Kann jemand mitmachen?", null = True, blank=False )
-    terms = NullBooleanField(help_text="")
+    orga            = CharField   ( 'Organisationsform',  max_length = 256, help_text="Organisationsform des Projektes.", null = True, blank=True )
+    mitmachen       = BooleanField( 'Mitmachen möglich', default=False, help_text="Kann jemand mitmachen?", null = True, blank=False )
+    terms           = NullBooleanField(help_text="")
 
     title = CharField('Product Title',max_length = 100,null = True, blank=True)
     country = CountryField(blank=True,multiple=True, help_text="")
@@ -234,12 +256,47 @@ class Product(models.Model):
     #interaction = ForeignKey(Interaction, null = True,on_delete = models.SET_NULL, help_text="")
 
     def __str__(self):
-        return str(self.title)
+        return str(self.name)
 
     def __iter__(self):
         for field in self._meta.fields:
             yield (field.verbose_name, field.value_to_string(self))
 
+    def get_field_verbose_name(self, fieldName):
+        return self._meta.get_field(fieldName).verbose_name
+
+    def meta(self):
+        return self._meta
+
+
+@receiver(post_delete, sender=Product)
+def auto_delete_reverse_keys(sender, instance, **kwargs):
+    if instance.credits:
+        instance.credits.delete()
+    if instance.description:
+        instance.description.delete()
+    if instance.interaction:
+        instance.interaction.delete()
+
+@receiver(post_save, sender=Product)
+def search_agent(sender, instance, created, raw, using, update_fields, **kwargs):
+    print(instance)
+    print(sender)
+    print(update_fields)
+    if update_fields != None:
+        print(update_fields)
+        if 'frei' in update_fields:
+            print('frei updated')
+
+
+class SearchAgent(models.Model):
+
+    def hash_gen():
+        return uuid.uuid1().hex
+
+    email           = EmailField         ( 'Email',   max_length = 2048, help_text="Email des Projektes", null = False, blank=False )
+    ort             = MultiSelectField   ( 'Ort', max_length = 4096 ,    choices=Product.ORT, default='WELT', help_text="Ort des Projektes", null = True, blank=False )
+    hash            = models.CharField   (max_length=255, default=hash_gen)
 
 class Wohnprojekt(Product):
 
@@ -250,9 +307,9 @@ class Wohnprojekt(Product):
         ('GTMIET', 'Getrennte Mietvertäge (Verein mietet GR)'),
     ]
 
-    UNTERST = [
-        ('GEFOR', 'Gefördert'),
-        ('NICHT', 'Nicht Gefördert'),
+    WOHNBAUFOERDERUNG = [
+        ('Gefördert', 'Gefördert'),
+        ('Nicht Gefördert', 'Nicht Gefördert'),
     ]
     ALTNEU = [
         ('ALTB', 'Altbau'),
@@ -344,17 +401,18 @@ class Wohnprojekt(Product):
     def kind_of_product(self):
             return "Wohnprojekt"
 
-    eigentum          = CharField   ( 'Rechtliche Konstruktion', max_length = 6,    choices=EIGENTUM, default='GEMIET', help_text="Rechtliche Konstruktion", null = True, blank=True )
-    inseratstext      = CharField   ( 'Inseratstext',   max_length = 2048,  help_text="Inseratstext", null = True, blank=True )
-    altneu            = CharField   ( 'Altbau/Neubau',  max_length = 4, choices=ALTNEU, help_text="Altbau/Neubau", null = True, blank=False )
+    eigentum          = CharField    ( 'Rechtliche Konstruktion', max_length = 6,    choices=EIGENTUM, default='GEMIET', help_text="Rechtliche Konstruktion", null = True, blank=True )
+    inseratstext      = CharField    ( 'Inseratstext',   max_length = 2048,  help_text="Inseratstext", null = True, blank=True )
+    altneu            = CharField    ( 'Altbau/Neubau',  max_length = 4, choices=ALTNEU, help_text="Altbau/Neubau", null = True, blank=False )
     schwerpunkt       = CharField    ( 'Inhaltlicher Schwerpunkt',   max_length = 2048,  help_text="Inhaltlicher Schwerpunkt", null = True, blank=True )
+    wohnbaufoerderung = CharField    ( 'Wohnbauförderung',    max_length = 4096,   choices=WOHNBAUFOERDERUNG, help_text="Wohnbauförderung", null = True, blank=True )
     artmodell         = CharField    ( 'Art der Modells',    max_length = 4096,   choices=ARTMODELL, help_text="Art der Modells", null = True, blank=True )
     bautraeger        = CharField    ( 'Bauträger',    max_length = 4096,   choices=BAUTRAEGER, help_text="Bauträger", null = True, blank=True )
     aerwachsene       = IntegerField( 'Anzahl an Erwachsenen', help_text="Anzahl an Erwachsenen", validators=[MinValueValidator(0), MaxValueValidator(9999)], null = True, blank=True )
     akinder           = IntegerField( 'Anzahl an Kinder', help_text="Anzahl an Kinder", validators=[MinValueValidator(0), MaxValueValidator(9999)], null = True, blank=True )
     @property
     def amitglieder(self):
-            return aerwachsene + akinder
+            return self.aerwachsene + self.akinder
     awohnungen        = IntegerField( 'Anzahl an Wohnungen', help_text="Anzahl an Wohnungen", validators=[MinValueValidator(0), MaxValueValidator(9999)], null = True, blank=True )
     wohnflaeche            = IntegerField( 'Wohnfläche', help_text="Wohnfläche", validators=[MinValueValidator(0)], default = 0, null = True, blank=True )
     gewerbeflaechen        = IntegerField( 'Gewerbeflächen', help_text="Gewerbeflächen", validators=[MinValueValidator(0)], default = 0, null = True, blank=True )
@@ -363,26 +421,23 @@ class Wohnprojekt(Product):
     @property
     def flaeche(self):
             return self.wohnflaeche + self.gewerbeflaechen + self.gemeinschaftsflaeche + self.sonstige_flaechen
-    gemeinschaftr      = MultiSelectField ( 'Gemeinschaftsräume',    max_length = 4096,   choices=GEMEINSCHAFTR, help_text="Gemeinschaftsräume", null = True, blank=True )
-    sonderwohnformen   = CharField        ( 'Sonderwohnformen',   max_length = 2048,  help_text="Sonderwohnformen, z.B. Wohncluster, WGs, Sonstiges", null = True, blank=True )
-    raumangebot        = MultiSelectField ( 'Raumangebot nach Außen',    max_length = 4096,   choices=RAUMANGEBOT, help_text="Raumangebot nach Außen", null = True, blank=True )
-    parbeiten          = IntegerField     ( 'Wie viele Personen arbeiten im Haus', help_text="Wie viele Personen arbeiten im Haus", validators=[MinValueValidator(0), MaxValueValidator(9999)], null = True, blank=True )
-    karbeiten          = CharField        ( 'Wie viele Personen arbeiten im Haus - Kommentar',   max_length = 2048,  help_text="Kommentar", null = True, blank=True )
-    bauweise           = CharField        ( 'Bauweise',  max_length = 64, choices=BAUWEISE, help_text="Bauweise", null = True, blank=True )
-    zielgruppen        = CharField        ( 'Besondere Zielgruppen',  max_length = 64, choices=ZIELGRUPPEN, help_text="Besondere Zielgruppen", null = True, blank=True )
-    gprojekte          = CharField        ( 'Gemeinschaftliche Projekte',  max_length = 64, choices=GPROJEKTE, help_text="Gemeinschaftliche Projekte", null = True, blank=True )
-    oekologie          = CharField        ( 'Ökologie',  max_length = 2048, help_text="Ökologie", null = True, blank=True )
-    freiraumangebote   = CharField        ( 'Freiraumangebote',  max_length = 64, choices=FREIANGEBOT, help_text="Freiraumangebote", null = True, blank=False )
-    gaestwohnungen     = IntegerField     ( 'Anzahl an Gästewohnungen', help_text="Anzahl an Gästewohnungen", validators=[MinValueValidator(0)], default = 0 )
+    kflaechen          = CharField         ( 'Flächen - Kommentar', max_length = 4096, help_text="Flächen - Kommentar", null = True, blank=True )
+    gemeinschaftr      = MultiSelectField  ( 'Gemeinschaftsräume',    max_length = 4096,   choices=GEMEINSCHAFTR, help_text="Gemeinschaftsräume", null = True, blank=True )
+    kgemeinschaftr     = CharField         ( 'Gemeinschaftsräume - Sonstiges', max_length = 4096, help_text="Gemeinschaftsräume - Sonstiges", null = True, blank=True )
+    sonderwohnformen   = CharField         ( 'Sonderwohnformen',   max_length = 2048,  help_text="Sonderwohnformen, z.B. Wohncluster, WGs, Sonstiges", null = True, blank=True )
+    raumangebot        = MultiSelectField  ( 'Raumangebot nach Außen',    max_length = 4096,   choices=RAUMANGEBOT, help_text="Raumangebot nach Außen", null = True, blank=True )
+    kraumangebot       = CharField         ( 'Raumangebot nach Außen - Sonstiges',    max_length = 4096,  help_text="Raumangebot nach Außen - Sonstiges", null = True, blank=True )
+    parbeiten          = IntegerField      ( 'Wie viele Personen arbeiten im Haus', help_text="Wie viele Personen arbeiten im Haus", validators=[MinValueValidator(0), MaxValueValidator(9999)], null = True, blank=True )
+    karbeiten          = CharField         ( 'Wie viele Personen arbeiten im Haus - Kommentar',   max_length = 2048,  help_text="Kommentar", null = True, blank=True )
+    bauweise           = CharField         ( 'Bauweise',  max_length = 64, choices=BAUWEISE, help_text="Bauweise", null = True, blank=True )
+    zielgruppen        = CharField         ( 'Besondere Zielgruppen',  max_length = 64, choices=ZIELGRUPPEN, help_text="Besondere Zielgruppen", null = True, blank=True )
+    gprojekte          = CharField         ( 'Gemeinschaftliche Projekte',  max_length = 64, choices=GPROJEKTE, help_text="Gemeinschaftliche Projekte", null = True, blank=True )
+    oekologie          = CharField         ( 'Ökologie',  max_length = 2048, help_text="Ökologie", null = True, blank=True )
+    freiraumangebote   = CharField         ( 'Freiraumangebote',  max_length = 64, choices=FREIANGEBOT, help_text="Freiraumangebote", null = True, blank=False )
+    gaestwohnungen     = IntegerField      ( 'Anzahl an Gästewohnungen', help_text="Anzahl an Gästewohnungen", validators=[MinValueValidator(0)], default = 0 )
+
+
 
-@receiver(post_delete, sender=Product)
-def auto_delete_reverse_keys(sender, instance, **kwargs):
-    if instance.credits:
-        instance.credits.delete()
-    if instance.description:
-        instance.description.delete()
-    if instance.interaction:
-        instance.interaction.delete()
 
 
 

+ 54 - 14
marktplatz/templates/marktplatz/product_detail.html

@@ -83,9 +83,10 @@
 
 
 					<div class="">
-						{{  product.get_mitmachen_display  }}
+						{{  product.mitmachen  }}
 					</div>
 
+					<p>{% if product.wohnprojekt.inseratstext  %}{% field_name product.wohnprojekt 'inseratstext' %}: {{ product.wohnprojekt.inseratstext }}{% endif %}</p>
 
 					<div class="">
 						&nbsp;
@@ -95,6 +96,8 @@
 
 					<p class=""> {{ product.learning }}</p>
 
+
+
 					<div class="">
 						&nbsp;
 					</div>
@@ -150,8 +153,12 @@
 					<p>Rechtsform: {{ product.wohnprojekt.rechtsform }}</p>
 					<p>{{ product.wohnprojekt.artmodell }}</p>
 					<p>{{ product.wohnprojekt.orga }}</p>
+					<p>{% if product.wohnprojekt.eigentum  %}{% field_name product.wohnprojekt 'eigentum' %}: {{ product.wohnprojekt.eigentum }}{% endif %}</p>
 					<p>Gemeinschaftliche Projekte: {{ product.wohnprojekt.gprojekte }}</p>
-					<p>Gemeinschaftsräume: {{ product.wohnprojekt.gemeinschaftr }}</p>
+					<p>Gemeinschaftsräume: {{ product.wohnprojekt.gemeinschaftr }}
+						{% if product.wohnprojekt.kgemeinschaftr  %} - {{ product.wohnprojekt.kgemeinschaftr }}{% endif %}
+					</p>
+
 					<p>{{ product.wohnprojekt.sonderwohnformen }}</p>
 					<p>Besondere Zielgruppen: {{ product.wohnprojekt.zielgruppen }}</p>
 					<p>Freiraumangebote: {{ product.wohnprojekt.freiraumangebote }}</p>
@@ -164,17 +171,22 @@
 
 					<p>{{ product.wohnprojekt.get_altneu_display }}, {{ product.wohnprojekt.bauweise }}</p>
 					<p>Bautr&auml;ger: {{ product.wohnprojekt.bautraeger }}</p>
-					<p>im Haus Wohnen ca {{ product.wohnprojekt.aerwachsene }} Erwachsene und {{  product.wohnprojekt.akinder }} Kinder</p>
+					<p>im Haus Wohnen ca {{ product.wohnprojekt.aerwachsene }} Erwachsene und {{  product.wohnprojekt.akinder }} Kinder.
+						Anzahl an Mitglieder: {{ product.wohnprojekt.amitglieder }}
+					</p>
 					<p>{{  product.wohnprojekt.awohnungen  }} Wohnungen</p>
-					<p>Gesamtnutzfläche: {{   product.wohnprojekt.flaeche }} m2</p>
-					<p>Wohnnutzfläche: {{  product.wohnprojekt.wohnflaeche  }} m2</p>
-					<p>gef&ouml;rdert als Wohnheim</p>
-					<p>Gemeinschaftfläche: {{ product.wohnprojekt.gemeinschaftsflaeche   }} m2</p>
-					<p>Gewerbefläche: {{ product.wohnprojekt.gewerbeflaechen  }} m2</p>
-					<p>Sonstige Flächen: {{ product.wohnprojekt.sonstige_flaechen  }} m2</p>
-					<p>Unsere Gewerbefläche sind ein Coworkingspace</p>
-					<p>Im Haus arbeiten ca {{ product.wohnprojekt.parbeiten }} Personen</p>
-
+					<p>{% if product.wohnprojekt.wohnflaeche  %}{% field_name product.wohnprojekt 'wohnflaeche' %}: {{ product.wohnprojekt.wohnflaeche }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.gewerbeflaechen  %}{% field_name product.wohnprojekt 'gewerbeflaechen' %}: {{ product.wohnprojekt.gewerbeflaechen }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.gemeinschaftsflaeche  %}{% field_name product.wohnprojekt 'gemeinschaftsflaeche' %}: {{ product.wohnprojekt.gemeinschaftsflaeche }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.sonstige_flaechen  %}{% field_name product.wohnprojekt 'sonstige_flaechen' %}: {{ product.wohnprojekt.sonstige_flaechen }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.flaeche  %}Fläche: {{ product.wohnprojekt.flaeche }}{% endif %}</p>
+					<p>{% if product.wohnprojekt.kflaechen  %}{% field_name product.wohnprojekt 'kflaechen' %}: {{ product.wohnprojekt.kflaechen }}{% endif %}</p>
+					<p>{% if product.wohnprojekt.gaestwohnungen  %}{% field_name product.wohnprojekt 'gaestwohnungen' %}: {{ product.wohnprojekt.gaestwohnungen }}{% endif %}</p>
+					<p>{% if product.wohnprojekt.wohnbaufoerderung  %}{% field_name product.wohnprojekt 'wohnbaufoerderung' %}: {{ product.wohnprojekt.wohnbaufoerderung }}{% endif %}</p>
+					<p>Im Haus arbeiten ca {{ product.wohnprojekt.parbeiten }} Personen {% if product.wohnprojekt.karbeiten  %}{{ product.wohnprojekt.karbeiten }}{% endif %}</p>
+					<p>{% if product.wohnprojekt.raumangebot  %}{% field_name product.wohnprojekt 'raumangebot' %}: {{ product.wohnprojekt.raumangebot }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.kraumangebot  %}{% field_name product.wohnprojekt 'kraumangebot' %}: {{ product.wohnprojekt.kraumangebot }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.schwerpunkt  %}{% field_name product.wohnprojekt 'schwerpunkt' %}: {{ product.wohnprojekt.schwerpunkt }}{% endif %}</p>
 
 					<br />
 					<h5 class="black mediumkur">Kontakt</h5>
@@ -210,6 +222,34 @@
 
 
 
+			    <!-- <p>{% if product.wohnprojekt.altneu  %}{% field_name product.wohnprojekt 'altneu' %}: {{ product.wohnprojekt.altneu }}{% endif %}</p> -->
+
+			    <!-- <p>{% if product.wohnprojekt.artmodell  %}{% field_name product.wohnprojekt 'artmodell' %}: {{ product.wohnprojekt.artmodell }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.bautraeger  %}{% field_name product.wohnprojekt 'bautraeger' %}: {{ product.wohnprojekt.bautraeger }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.aerwachsene  %}{% field_name product.wohnprojekt 'aerwachsene' %}: {{ product.wohnprojekt.aerwachsene }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.akinder  %}{% field_name product.wohnprojekt 'akinder' %}: {{ product.wohnprojekt.akinder }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.amitglieder  %}Anzahl an Mitglieder: {{ product.wohnprojekt.amitglieder }}{% endif %}</p> -->
+
+			    <!-- <p>{% if product.wohnprojekt.awohnungen  %}{% field_name product.wohnprojekt 'awohnungen' %}: {{ product.wohnprojekt.awohnungen }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.wohnflaeche  %}{% field_name product.wohnprojekt 'wohnflaeche' %}: {{ product.wohnprojekt.wohnflaeche }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.gewerbeflaechen  %}{% field_name product.wohnprojekt 'gewerbeflaechen' %}: {{ product.wohnprojekt.gewerbeflaechen }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.gemeinschaftsflaeche  %}{% field_name product.wohnprojekt 'gemeinschaftsflaeche' %}: {{ product.wohnprojekt.gemeinschaftsflaeche }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.sonstige_flaechen  %}{% field_name product.wohnprojekt 'sonstige_flaechen' %}: {{ product.wohnprojekt.sonstige_flaechen }}{% endif %}</p>
+			    <p>{% if product.wohnprojekt.flaeche  %}Fläche: {{ product.wohnprojekt.flaeche }}{% endif %}</p> -->
+
+			    <!-- <p>{% if product.wohnprojekt.gemeinschaftr  %}{% field_name product.wohnprojekt 'gemeinschaftr' %}: {{ product.wohnprojekt.gemeinschaftr }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.kgemeinschaftr  %}{% field_name product.wohnprojekt 'kgemeinschaftr' %}: {{ product.wohnprojekt.kgemeinschaftr }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.sonderwohnformen  %}{% field_name product.wohnprojekt 'sonderwohnformen' %}: {{ product.wohnprojekt.sonderwohnformen }}{% endif %}</p> -->
+
+			    <!-- <p>{% if product.wohnprojekt.parbeiten  %}{% field_name product.wohnprojekt 'parbeiten' %}: {{ product.wohnprojekt.parbeiten }}{% endif %}</p> -->
+
+			    <!-- <p>{% if product.wohnprojekt.bauweise  %}{% field_name product.wohnprojekt 'bauweise' %}: {{ product.wohnprojekt.bauweise }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.zielgruppen  %}{% field_name product.wohnprojekt 'zielgruppen' %}: {{ product.wohnprojekt.zielgruppen }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.gprojekte  %}{% field_name product.wohnprojekt 'gprojekte' %}: {{ product.wohnprojekt.gprojekte }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.oekologie  %}{% field_name product.wohnprojekt 'oekologie' %}: {{ product.wohnprojekt.oekologie }}{% endif %}</p> -->
+			    <!-- <p>{% if product.wohnprojekt.freiraumangebote  %}{% field_name product.wohnprojekt 'freiraumangebote' %}: {{ product.wohnprojekt.freiraumangebote }}{% endif %}</p> -->
+
+
 
 
 				</div>
@@ -225,7 +265,7 @@
 		<div class="col-sm-6">
 
 				{% for link in product.link_set.all %}
-					<p> <a href="{{link.link}}">{{link.link}}</a></p>
+					<!-- <p> <a href="{{link.link}}">{{link.link}}</a></p> -->
 				{% endfor %}
 
 
@@ -234,7 +274,7 @@
 
 			 				 {% for field, value in product.wohnprojekt %}
 			          {% if value and not field == "ID" %}
-			           <p class="fieldname"><strong class="mediumkur"> {{ field }} :</strong> {{ value }}</p>
+			           <!-- <p class="fieldname"><strong class="mediumkur"> {{ field }} :</strong> {{ value }}</p> -->
 			          {% endif %}
 			          {% endfor %}
 

+ 38 - 0
marktplatz/templatetags/tags.py

@@ -6,6 +6,44 @@ from django.db.models import Avg
 register = template.Library()
 from ..models import Product, User, Vote, Media, Contact
 
+
+
+# @register.simple_tag
+# def model_name(obj):
+#     '''
+#     Django template filter which returns the verbose name of a model.
+#     '''
+#     if hasattr(obj, 'model'):
+#         obj = obj.model
+#
+#     return obj._meta.verbose_name.title()
+#
+#
+# @register.simple_tag
+# def model_name_plural(obj):
+#     '''
+#     Django template filter which returns the plural verbose name of a model.
+#     '''
+#     if hasattr(obj, 'model'):
+#         obj = obj.model
+#
+#     return obj._meta.verbose_name_plural.title()
+
+
+@register.simple_tag
+def field_name(obj, field):
+    '''
+    Django template filter which returns the verbose name of an object's,
+    model's or related manager's field.
+    '''
+    # if hasattr(obj, 'model'):
+    #     obj = obj.model
+
+    return obj._meta.get_field(field).verbose_name.title().capitalize()
+
+
+
+
 @register.simple_tag
 def get_vote(Product, user):
     if user.groups.filter(name='jury').exists():

+ 1 - 0
marktplatz/urls.py

@@ -11,6 +11,7 @@ urlpatterns = [
     path('about/', views.about, name='about'),
     path('submit/', views.submit, name='submit'),
     path('products/', views.ProductsView.as_view(), name='products'),
+    path('suchagent/', views.SearchAgentCreate.as_view(), name='search-agent-create'),
     path('product/<int:pk>', views.DetailView.as_view(), name='product-detail'),
     path('votes/', views.VoteView.as_view(), name='vote-detail'),
     path('votescid/', views.CidView.as_view(), name='votecid-detail'),

+ 19 - 50
marktplatz/views.py

@@ -1,6 +1,7 @@
 from django.shortcuts import render
 from django.views import generic
 from django.views.generic import TemplateView
+from django.views.generic.edit import *
 from marktplatz.models import *
 from django.db import models
 from django.contrib.auth.models import User
@@ -10,7 +11,7 @@ from django.core.mail import send_mail
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.models import User, Group
 from django.http import HttpResponseRedirect
-from django.urls import reverse
+from django.urls import reverse, reverse_lazy
 from django.core.files import File
 from django.http import HttpResponse
 from django.views.generic import FormView
@@ -73,6 +74,12 @@ def home(request):
         return  HttpResponseRedirect(reverse('products'))
 
 
+class SearchAgentCreate(CreateView):
+    model = SearchAgent
+    template_name =  'marktplatz/form.html'
+    fields =  'ort', 'email'
+    success_url = reverse_lazy('products')
+
 class ProductsView(generic.ListView):
     model = Product
     #context_object_name = 'Products'
@@ -138,13 +145,17 @@ class DetailView(generic.DetailView):
             # context['interactions'] = Interaction.objects.select_related().get(product=self.kwargs['pk'])
             # context['PAUI'] = Category.objects.get(short_name='PAUI')
             # context['wohnprojekt'] = self.object.wohnprojekt
-
+            # print (context)
+            # print (context['object'])
+            # print (context['product'])
             return context
 
+
     def post(self, request, *args, **kwargs):
         vote = int(request.POST['vote'])
         comment = str(request.POST['comment'])
 
+
         if vote <= 10:
 
              try:
@@ -216,7 +227,6 @@ class AdminView(LoginRequiredMixin, generic.ListView):
     def post(self, request, *args, **kwargs):
         for pk in request.POST.dict():
             print(pk)
-            print("test")
             if not 'csrfmiddlewaretoken' in pk:
                 if request.POST[pk] != '' and ('public' in pk):
                     pass
@@ -289,7 +299,7 @@ class registerView(FormView):
 
     def post(self, request):
 
-        print (  request.POST.dict()  )
+        # print (  request.POST.dict()  )
         form = SignUpForm(request.POST)
         form_contact = RegisterForm(request.POST)
 
@@ -348,10 +358,6 @@ class registerView(FormView):
 
             login(request, user)
 
-
-
-
-
         else:
 
 
@@ -416,7 +422,6 @@ class NewSubmitView(LoginRequiredMixin, FormView):
     def post(self, request):
 
         product_f   = SubmissionForm(request.POST, request.FILES)
-        # lnks_f      = LinkFormSet(request.POST)
 
         if product_f.is_valid():
 
@@ -431,12 +436,6 @@ class NewSubmitView(LoginRequiredMixin, FormView):
             product.save()
             product_f.save_m2m()
 
-            # for lnk in lnks_f:
-            #     if lnk.is_valid():
-            #         lnk_ = lnk.save(commit=False)
-            #         lnk_.product=product
-            #         lnk_.save()
-
             if 'addImage' in request.POST:
                 return HttpResponseRedirect(reverse('add-Image', kwargs={'pk': product.pk}))
 
@@ -447,8 +446,6 @@ class NewSubmitView(LoginRequiredMixin, FormView):
             context = request.POST.dict()
             context['product'] =        product_f
             context['product_errors']  = product_f.errors
-            # context['lnks'] =           lnks_f
-            # context['lnks_helper'] =    FormsetHelper()
             context['use_ajax'] = True
             return render(request, self.template_name, context)
 
@@ -592,9 +589,12 @@ class EditView(FormView):
         vid1_f = VideoForm(request.POST, request.FILES)
 
         if product_f.is_valid():
-
+            update_fields = []
+            # https://stackoverflow.com/questions/35879101/how-to-determine-if-a-field-has-changed-in-a-django-modelform/43550210
             if product_f.has_changed():
-                product_f.save()
+                if 'frei' in product_f.changed_data:
+                    print('frei changed')
+                product_f.save( )
 
             product = product_f.save()
             # for lnk in lnks_f:
@@ -679,34 +679,3 @@ def delete_video(request, pk):
         raise Http404
     object.delete()
     return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
-
-#class datetimeadd(LoginRequiredMixin, TemplateView):
-#
-#        template_name = "marktplatz/importold.html"
-#
-#        def post(self, request):
-#            context = {'faild': ''}
-#            faild = ''
-#            from1 = int(request.POST['from'])
-#            to = int(request.POST['to'])
-#
-#            Products = Product.objects.all()
-#            i = 0
-#
-#            for Product in Products:
-#                i += 1
-#                if (i < from1):
-#                    continue
-#                if (i > to):
-#                    break
-#
-#               if Product.date_submitted >
-#
-#            return render(request, self.template_name, context)
-#
-#        def get(self, request):
-#            context = {'faild': ''}
-#            faild = ''
-#            context['faild'] = faild
-#
-#            return render(request, self.template_name, context)

+ 19 - 51
project_base/settings.py

@@ -134,7 +134,6 @@ SPONSOR_CARDS = """
                     <button class="border-thin mybtn" style="margin-right: 2px;margin-bottom: 2px">#NAME</button>
                 </nobr>
             </a>
-
         </p>
     </div>
 </div>
@@ -142,15 +141,14 @@ SPONSOR_CARDS = """
 
 ABOUT_TEXT = """
   {% load static %}
-<div class="container" style="margin-top: 20px;">
-<h3>MAB Catalogue</h3>
-<br />
+<p>Marktplatz </p>
 <p>&nbsp;</p>
-<p><small> <strong>Our Sponsors:</strong><br />  -<br /> </small></p>
-<p><small> <strong>Exhibition curators</strong><br />-<br /> </small></p>
-<p><small> <strong>System developer</strong><br /> -<br /> </small></p>
-<p><small> <strong>This is a website by </strong><br /> <img src="{% static 'logo_MAI.jpg' %}" width="auto" height="50px" /><br /> Gisela Legath-Gasse 5 / 1<br /> 1220 Vienna &ndash; Austria<br /> <a href="www.mediaarchitecture.org">www.mediaarchitecture.org</a><br /> awards@mediaarchitecture.org<br /> ZVR-Zahl: 501926485<br /> ATU69058814<br /><br /> Please have a look at our privacy policy: <br /> <a href="https://www.mediaarchitecture.org/privacy-policy/">https://www.mediaarchitecture.org/privacy-policy/</a><br /> </small></p>
-</div>
+<p>Unsere Sponsoren:<br />- -</p>
+<p>Systementwickler<br />- -</p>
+<p>Dies ist eine Website von</p>
+<p>RealityLab</p>
+<p>Gisela Legath-Gasse 5/1<br />1220 Wien - &Ouml;sterreich<br />www.realitylab.at<br />office@realitylab.at</p>
+<p>Bitte beachten Sie unsere Datenschutzbestimmungen:<br />https://www.realitylab.at/privacy-policy/</p>
 """
 
 MAIN_CARD = """
@@ -176,50 +174,13 @@ MAIN_CARD = """
   """
 
 INFO_TXT = """
-<div><span style="font-weight: bold;">Please note:</span></div>
-<ul><li><div>Fill in as <span style="font-weight: bold;">many fields</span> as possible.</div></li>
-<li><div><span style="font-weight: bold;">Mandatory fields</span> are marked with an asterisk*.</div></li>
-<li><div>Don’t forget to press the <span style="font-weight: bold;">„Save“ button</span> from time to time ;-)</div></li>
-<li><div>Feel free to <span style="font-weight: bold;">share this form</span> within your team and partners, so that they can add additional information. (They have to use the same login as you)</div></li>
-<li><div><span style="font-weight: bold;">Please note that you can edit all entries until the deadline</span></div></li>
-<li><div><span style="font-weight: bold;">The deadline is &nbsp;June 14 2020 at 10:00 pm</span></div></li></ul>
-<div><span style="font-weight: bold;">After the deadline we take what is in the form. So make sure that least all required fields are filled in and you have added at least 4 media (Photos or Videos) You can only add media after you have entered all mandatory fields.</span></div>
-<div><br></div><div><span style="font-weight: bold;">So, have fun!&nbsp;</span>
-<span style="font-weight: bold;">We really look forward to your project!</span></div>
-<div><span style="font-weight: bold;">Hopefully see you in Amsterdam,</span></div>
-<div><span style="font-weight: bold;">Gernot and the MAB Team!</span></div>
+<p>Bitte beachten Sie:</p>
+<p>F&uuml;llen Sie so viele Felder wie m&ouml;glich aus.<br /> Pflichtfelder sind mit einem Sternchen gekennzeichnet*.</p>
 """
 
 SUBMIT_TEXT = """
-
-<div>Yes you got it! On this page you can submit proposals to the MAB20 Awards!</div><div><br></div>
-<div>We are pleased to announce that the international Media Architecture Biennale 2020, will take place 23 · 27 November 2020 in Amsterdam / Utrecht in the Netherlands.</div>
-<div><br></div><div>In order to submit projects to the MAB Awards pls proceed as follows:</div>
-<div><br></div><ol><li><div style="text-align: left;"><span style="font-size: 14px; text-decoration: underline;">download the MAB Awards Call (PDF)</span></div>
-</li><li><div style="text-align: left;"><a href="/mab/register/">register</a></div></li>
-<li><div style="text-align: left;"><a href="/mab/addProject/?">submit your project&nbsp;</a></div></li></ol>
-<div style="margin-top: 1em; margin-bottom: 1em;"></div><div style="margin-top: 1em; margin-bottom: 1em;"></div>
-<div>You can invite your team and partners to fill in the project form. (They have to use the same login as you)</div>
-<div>It’s work in progress. ;.-) You don’t have to fill in everything at one time and you can edit all entries until the deadline.</div>
-<div><span style="font-weight: bold;">The deadline is &nbsp;June 14 2020 at 10:00 pm</span></div><div><br>
-</div><div>So, have fun!&nbsp;We really look forward to your project!</div><div>Hopefully see you in Amsterdam,</div>
-<div>Gernot and the MAB Team!</div><div><br></div><div style="margin-top: 1em; margin-bottom: 1em;"></div>
-<div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">JURY MEMBERS:</span>
-</div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Martijn de Waal</span><span data-en-paragraph="true" data-en-has-metadata="true"> – University of Applied Sciences, Amsterdam</span></div>
-<div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true">
-<span style="font-weight: bold;">Gernot Tscherteu</span> - Media Architecture Institute, Vienna</span></div>
-<div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Juan Carlos Carvajal B.</span><span data-en-paragraph="true" data-en-has-metadata="true"> –&nbsp;</span><span data-en-paragraph="true" data-en-has-metadata="true">Media Architecture Institute, Vienna</span></div><div style="margin-top: 1em; margin-bottom: 1em;">
-<span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Susa Pop</span><span data-en-paragraph="true" data-en-has-metadata="true"> – Public Art Lab, Berlin
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Tanya Toft Ag</span><span data-en-paragraph="true" data-en-has-metadata="true"> – Urban Media Art Academy, Hong Kong
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Luke Hespanhol</span><span data-en-paragraph="true" data-en-has-metadata="true"> – The University of Sydney, Sydney
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Ava Fatah gen. Schieck</span><span data-en-paragraph="true" data-en-has-metadata="true"> – The Bartlett, University College London
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Dave Colangelo</span><span data-en-paragraph="true" data-en-has-metadata="true"> – Portland State University, Portland
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">Martin Tomitsch</span><span data-en-paragraph="true" data-en-has-metadata="true"> – The University of Sydney, Sydney
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span data-en-paragraph="true" data-en-has-metadata="true" style="font-weight: bold;">M. Hank Haeusler</span><span data-en-paragraph="true" data-en-has-metadata="true"> – UNSW Sydney
-</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><br></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="font-weight: bold;">We would like to thank our sponsors:</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><br></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="font-weight: bold;">Sponsors</span></div>
-<div style="margin-top: 1em; margin-bottom: 1em;"><br></div>
-</div>
-
+<p><br />Wir m&ouml;chten uns bei unseren Sponsoren bedanken:</p>
+<p>Sponsoren</p>
 """
 
 CONSTANCE_ADDITIONAL_FIELDS = {
@@ -260,6 +221,7 @@ INSTALLED_APPS = [
     'django_file_form.ajaxuploader',
     'django_countries',
     'captcha',
+    'debug_toolbar',
 ]
 
 CRISPY_TEMPLATE_PACK = 'bootstrap4'
@@ -268,9 +230,14 @@ CRISPY_TEMPLATE_PACK = 'bootstrap4'
 CAPTCHA_NOISE_FUNCTIONS=('captcha.helpers.noise_dots',)
 CAPTCHA_LETTER_ROTATION=(-15,15)
 
-
+INTERNAL_IPS = [
+    # ...
+    '127.0.0.1',
+    # ...
+]
 
 MIDDLEWARE = [
+    'debug_toolbar.middleware.DebugToolbarMiddleware',
     'django.middleware.security.SecurityMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.common.CommonMiddleware',
@@ -278,6 +245,7 @@ MIDDLEWARE = [
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
+
 ]
 
 # 'htmlmin.middleware.HtmlMinifyMiddleware',

+ 5 - 1
project_base/urls.py

@@ -14,15 +14,18 @@ Including another URLconf
     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
 """
 from django.contrib import admin
-from django.conf.urls import include
 from django.urls import path, re_path
 from django.views.generic import RedirectView
 from django.conf import settings
 from django.conf.urls.static import static
 from django.contrib.auth import views as auth_views
+from django.urls import include, path
+
 from django.conf.urls import url, include
 from . import views
 
+import debug_toolbar
+
 
 from .views import *
 
@@ -62,6 +65,7 @@ urlpatterns = [
     path('accounts/', include('django.contrib.auth.urls')),
     url(r'^upload/', include('django_file_form.urls')),
     url(r'^handle_upload$', views.handle_upload, name='file_form_handle_upload'),
+    path('__debug__/', include(debug_toolbar.urls)),
     #path('resetpwd/', auth_views.PasswordResetForm, name='password_reset'),
 ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
 

+ 1 - 0
requirements.txt

@@ -11,3 +11,4 @@ django-picklefield==2.1.1
 django-countries==5.5
 django-simple-captcha==0.5.12
 django-multiselectfield==0.1.12
+django-debug-toolbar==3.1.1