|
|
@@ -9,6 +9,7 @@ from django.core.validators import MinValueValidator, MaxValueValidator
|
|
|
from django.contrib.auth.models import User
|
|
|
from django.core.files.storage import FileSystemStorage
|
|
|
from django_countries.fields import CountryField
|
|
|
+from django.urls import reverse
|
|
|
|
|
|
from django.db import models
|
|
|
from django.dispatch import receiver
|
|
|
@@ -128,79 +129,65 @@ 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, update_fields=None, *args, **kwargs):
|
|
|
- print ("is this workig?")
|
|
|
+ def save(self, update_fields=None, *args, **kwargs):
|
|
|
+ # print ("is this workig?")
|
|
|
+ # if self.frei != self.__original_frei and self.frei == "JAJA":
|
|
|
+ # print ( "activates --------")
|
|
|
+ # self.frei_activated = True
|
|
|
|
|
|
-
|
|
|
- print ('update_fields: ', update_fields)
|
|
|
+ # print ('update_fields: ', update_fields)
|
|
|
# post_save.connect(search_agent)
|
|
|
- if self.frei != self.__original_frei and self.frei == "JAJA":
|
|
|
- for agent in SearchAgent.objects.all():
|
|
|
- for agentOrt in agent.ort:
|
|
|
- print(agentOrt)
|
|
|
- if agentOrt == self.ort:
|
|
|
- print ('send_mail')
|
|
|
-
|
|
|
- context = {}
|
|
|
-
|
|
|
- context['product_name']=self.name
|
|
|
- context['product_claim']=self.claim
|
|
|
- context['product_beschreibung']=self.beschreibung
|
|
|
- context['product_learning']=self.learning
|
|
|
- context['product_gruendungsjahr']=self.gruendungsjahr
|
|
|
- context['product_betriebgenommen']=self.betriebgenommen
|
|
|
- context['product_status']=self.status
|
|
|
- context['product_adresse']=self.adresse
|
|
|
- context['product_plz']=self.plz
|
|
|
- context['product_adresse_zusatz']=self.adresse_zusatz
|
|
|
- context['product_ort']=self.ort
|
|
|
- context['product_website']=self.website
|
|
|
- context['product_email']=agent.hash
|
|
|
- context['agent_hash']=self.email
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- context['recipient'] = [ agent.email, ]
|
|
|
- context['msg_subject' ] = ('Gemeinschaffen - ' + self.name )
|
|
|
-
|
|
|
- mail.send(
|
|
|
- context['recipient'],
|
|
|
- config.EMAIL_NOREPLY,
|
|
|
- context = context,
|
|
|
- template='generic',
|
|
|
- headers={ 'Reply-To': context['product_email'] },
|
|
|
- priority='now',
|
|
|
- )
|
|
|
|
|
|
+ # if self.frei != self.__original_frei and self.frei == "JAJA":
|
|
|
+ # for agent in SearchAgent.objects.all():
|
|
|
+ # for agentOrt in agent.ort:
|
|
|
+ # print(agentOrt)
|
|
|
+ # if agentOrt == self.ort:
|
|
|
+ # print ('send_mail')
|
|
|
+ #
|
|
|
+ # context = {}
|
|
|
+ #
|
|
|
+ # print ( reverse('search-agent-delete' , kwargs={ 'pk': agent.pk, 'hash': agent.hash } ) )
|
|
|
+ #
|
|
|
+ # context['product_name']=self.name
|
|
|
+ # context['product_claim']=self.claim
|
|
|
+ # context['product_beschreibung']=self.beschreibung
|
|
|
+ # context['product_learning']=self.learning
|
|
|
+ # context['product_gruendungsjahr']=self.gruendungsjahr
|
|
|
+ # context['product_betriebgenommen']=self.betriebgenommen
|
|
|
+ # context['product_status']=self.status
|
|
|
+ # context['product_adresse']=self.adresse
|
|
|
+ # context['product_plz']=self.plz
|
|
|
+ # context['product_adresse_zusatz']=self.adresse_zusatz
|
|
|
+ # context['product_ort']=self.ort
|
|
|
+ # context['product_website']=self.website
|
|
|
+ # context['product_email']=agent.hash
|
|
|
+ # context['agent_hash']=self.email
|
|
|
+ #
|
|
|
+ #
|
|
|
+ #
|
|
|
+ # context['recipient'] = [ agent.email, ]
|
|
|
+ # context['msg_subject' ] = ('Gemeinschaffen - ' + self.name )
|
|
|
+ #
|
|
|
+ # mail.send(
|
|
|
+ # context['recipient'],
|
|
|
+ # config.EMAIL_NOREPLY,
|
|
|
+ # context = context,
|
|
|
+ # template='generic',
|
|
|
+ # headers={ 'Reply-To': context['product_email'] },
|
|
|
+ # priority='now',
|
|
|
+ # )
|
|
|
|
|
|
- super().save( update_fields=update_fields, *args, **kwargs) # Call the "real" save() method.
|
|
|
- self.__original_frei = self.frei
|
|
|
- # super().save(update_fields=update_fields, *args, **kwargs) # Call the "real" save() method.
|
|
|
|
|
|
- # def save(self, *args, update_fields=[''], **kwargs):
|
|
|
+ super().save( update_fields=update_fields, *args, **kwargs) # Call the "real" save() method.
|
|
|
|
|
|
- #
|
|
|
- #
|
|
|
- # # super(Product, self).save(force_insert, force_update, update_fields=['frei'], *args, **kwargs)
|
|
|
- # print ("savingg.....")
|
|
|
- # super().save(*args, update_fields=['frei'], **kwargs)
|
|
|
- # print ("saved ++++++++")
|
|
|
- #
|
|
|
|
|
|
STATUS = [
|
|
|
('ENT', 'Entwicklung'),
|
|
|
@@ -457,8 +444,8 @@ class Wohnprojekt(Product):
|
|
|
wohnbaufoerderung = CharField ( 'Wohnbauförderung', max_length = 1024, choices=WOHNBAUFOERDERUNG, help_text="Wohnbauförderung", null = True, blank=True )
|
|
|
artmodell = TextField ( 'Art der Modells', max_length = 2048, help_text="Art der Modells", null = True, blank=True )
|
|
|
bautraeger = TextField ( 'Bauträger', max_length = 2048, 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 )
|
|
|
+ aerwachsene = IntegerField( 'Anzahl an Erwachsenen', help_text="Anzahl an Erwachsenen", validators=[MinValueValidator(0), MaxValueValidator(9999)], default = 0, null = True, blank=False )
|
|
|
+ akinder = IntegerField( 'Anzahl an Kinder', help_text="Anzahl an Kinder", validators=[MinValueValidator(0), MaxValueValidator(9999)], default = 0, null = True, blank=False )
|
|
|
@property
|
|
|
def amitglieder(self):
|
|
|
return self.aerwachsene + self.akinder
|
|
|
@@ -482,7 +469,7 @@ class Wohnprojekt(Product):
|
|
|
zielgruppen = CharField ( 'Besondere Zielgruppen', max_length = 64, help_text="Besondere Zielgruppen", null = True, blank=True )
|
|
|
gprojekte = CharField ( 'Gemeinschaftliche Projekte', max_length = 64, help_text="Gemeinschaftliche Projekte", null = True, blank=True )
|
|
|
oekologie = CharField ( 'Ökologie', max_length = 1024, help_text="Ökologie", null = True, blank=True )
|
|
|
- freiraumangebote = CharField ( 'Freiraumangebote', max_length = 64, choices=FREIANGEBOT, help_text="Freiraumangebote", null = True, blank=False )
|
|
|
+ freiraumangebote = CharField ( 'Freiraumangebote', max_length = 64, choices=FREIANGEBOT, help_text="Freiraumangebote", null = True, blank=True )
|
|
|
gaestwohnungen = IntegerField ( 'Anzahl an Gästewohnungen', help_text="Anzahl an Gästewohnungen", validators=[MinValueValidator(0)], default = 0 )
|
|
|
|
|
|
|