|
|
@@ -24,9 +24,12 @@ from imagekit.processors import Thumbnail
|
|
|
from imagekit.processors import ResizeToCover
|
|
|
from imagekit.models import ProcessedImageField
|
|
|
|
|
|
+from post_office import mail
|
|
|
+from constance import config
|
|
|
|
|
|
from marktplatz.widgets import *
|
|
|
|
|
|
+
|
|
|
class Credit(models.Model):
|
|
|
owner = CharField(verbose_name='Building or Product owner',blank=True,max_length = 300)
|
|
|
architecture = CharField(verbose_name='Architecture',blank=True,max_length = 300)
|
|
|
@@ -139,35 +142,66 @@ class Product(models.Model):
|
|
|
super(Product, self).__init__(*args, **kwargs)
|
|
|
self.__original_frei = self.frei
|
|
|
|
|
|
- def save(self, force_insert=False, update_fields=[''], force_update=False, *args, **kwargs):
|
|
|
- if self.frei != self.__original_frei:
|
|
|
- if 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 ['base_uri'] = self.request.build_absolute_uri( '/' ).rstrip('/')
|
|
|
- # context['recipient'] = [ myActivity.contact.email, ]
|
|
|
- # context['msg_subject' ] = _('Activity created')
|
|
|
- # context['msg_content' ] = "\n" + "<br/>" + \
|
|
|
- # _("Title: ") + form.cleaned_data['title'] + "\n" + "<br/><br/>" + \
|
|
|
- # _('Description: ') + form.cleaned_data['description'] + "\n" + "<br/>"
|
|
|
- #
|
|
|
- # mail.send(
|
|
|
- # context['recipient'],
|
|
|
- # config.EMAIL_NOREPLY,
|
|
|
- # context = context,
|
|
|
- # template='generic',
|
|
|
- # headers={ 'Reply-To': context['email'] },
|
|
|
- # priority='now',
|
|
|
- # )
|
|
|
-
|
|
|
-
|
|
|
- super(Product, self).save(force_insert, force_update, update_fields=['frei'], *args, **kwargs)
|
|
|
+
|
|
|
+ def save(self, update_fields=None, *args, **kwargs):
|
|
|
+ print ("is this workig?")
|
|
|
+
|
|
|
+
|
|
|
+ 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',
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+ 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(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'),
|
|
|
@@ -252,7 +286,7 @@ class Product(models.Model):
|
|
|
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 = 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 )
|
|
|
+ mitmachen = BooleanField( 'Mitmachen möglich', default=False, help_text="Kann jemand mitmachen?", blank=False )
|
|
|
terms = NullBooleanField(help_text="")
|
|
|
|
|
|
title = CharField('Product Title',max_length = 100,null = True, blank=True)
|
|
|
@@ -301,15 +335,7 @@ def auto_delete_reverse_keys(sender, instance, **kwargs):
|
|
|
if instance.interaction:
|
|
|
instance.interaction.delete()
|
|
|
|
|
|
-@receiver(post_save, sender=Product)
|
|
|
-def search_agent(sender, instance, **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):
|
|
|
@@ -437,10 +463,10 @@ class Wohnprojekt(Product):
|
|
|
def amitglieder(self):
|
|
|
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 )
|
|
|
- gemeinschaftsflaeche = IntegerField( 'Gemeinschaftsflächen', help_text="Gemeinschaftsflächen", validators=[MinValueValidator(0)], default = 0, null = True, blank=True )
|
|
|
- sonstige_flaechen = IntegerField( 'Sonstige Flächen', help_text="Sonstige Flächen", validators=[MinValueValidator(0)], default = 0, null = True, blank=True )
|
|
|
+ wohnflaeche = IntegerField( 'Wohnfläche', help_text="Wohnfläche", validators=[MinValueValidator(0)], default = 0, null = True, )
|
|
|
+ gewerbeflaechen = IntegerField( 'Gewerbeflächen', help_text="Gewerbeflächen", validators=[MinValueValidator(0)], default = 0, null = True, )
|
|
|
+ gemeinschaftsflaeche = IntegerField( 'Gemeinschaftsflächen', help_text="Gemeinschaftsflächen", validators=[MinValueValidator(0)], default = 0, null = True, )
|
|
|
+ sonstige_flaechen = IntegerField( 'Sonstige Flächen', help_text="Sonstige Flächen", validators=[MinValueValidator(0)], default = 0, null = True, )
|
|
|
@property
|
|
|
def flaeche(self):
|
|
|
return self.wohnflaeche + self.gewerbeflaechen + self.gemeinschaftsflaeche + self.sonstige_flaechen
|