|
@@ -122,6 +122,28 @@ class Category(models.Model):
|
|
|
|
|
|
|
|
class Product(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 = [
|
|
STATUS = [
|
|
|
('ENT', 'Entwicklung'),
|
|
('ENT', 'Entwicklung'),
|
|
|
('BET', 'In Betrieb'),
|
|
('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 )
|
|
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 )
|
|
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 )
|
|
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)
|
|
title = CharField('Product Title',max_length = 100,null = True, blank=True)
|
|
|
country = CountryField(blank=True,multiple=True, help_text="")
|
|
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="")
|
|
#interaction = ForeignKey(Interaction, null = True,on_delete = models.SET_NULL, help_text="")
|
|
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
|
- return str(self.title)
|
|
|
|
|
|
|
+ return str(self.name)
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
def __iter__(self):
|
|
|
for field in self._meta.fields:
|
|
for field in self._meta.fields:
|
|
|
yield (field.verbose_name, field.value_to_string(self))
|
|
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):
|
|
class Wohnprojekt(Product):
|
|
|
|
|
|
|
@@ -250,9 +307,9 @@ class Wohnprojekt(Product):
|
|
|
('GTMIET', 'Getrennte Mietvertäge (Verein mietet GR)'),
|
|
('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 = [
|
|
ALTNEU = [
|
|
|
('ALTB', 'Altbau'),
|
|
('ALTB', 'Altbau'),
|
|
@@ -344,17 +401,18 @@ class Wohnprojekt(Product):
|
|
|
def kind_of_product(self):
|
|
def kind_of_product(self):
|
|
|
return "Wohnprojekt"
|
|
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 )
|
|
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 )
|
|
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 )
|
|
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 )
|
|
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 )
|
|
akinder = IntegerField( 'Anzahl an Kinder', help_text="Anzahl an Kinder", validators=[MinValueValidator(0), MaxValueValidator(9999)], null = True, blank=True )
|
|
|
@property
|
|
@property
|
|
|
def amitglieder(self):
|
|
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 )
|
|
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 )
|
|
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 )
|
|
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
|
|
@property
|
|
|
def flaeche(self):
|
|
def flaeche(self):
|
|
|
return self.wohnflaeche + self.gewerbeflaechen + self.gemeinschaftsflaeche + self.sonstige_flaechen
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|