Repository: liqd/a4-meinberlin

Issue:
when bplan is archived, office worker update email is sent
**URL:** 
**user:** 
**expected behaviour:** Office workers only get an update email when bplan is "published, changed or created as draft"
**behaviour:** The automatic archiving also changes the bplan and by that triggers the email. Thinking about it, it should also trigger the get-point thing (and might result in failure errors being thrown).
**important screensize:**
**device & browser:** 
**Comment/Question:** 

Screenshot?



Discussion:
@CarolingerSeilchenspringer I think we should investigate and fix this rather quickly, right?! Not sure if prio should be high or medium, though. When is the next scheduled release?
@fuzzylogic2000 what is the "get-point thing"? but you are right, this may be quite confusing for office worker. It should have time till next scheduled release end of september. 
@CarolingerSeilchenspringer That is the script that checks for point and district in the bplan map.
@fuzzylogic2000 ah thanks. So can we make the archiving not trigger mail and get-point thing? Alternatively we could also write in the mail that the mail is send when the project finishes and automatically is being archived.
@CarolingerSeilchenspringer No, we can make it not sent the email and trigger the get-point thing. :)
@fuzzylogic2000 just saw that this is also in the milestone. If you manage to fix before monday, it's good, if not, we'll do it with next release. I'll leave it in the milestone for now.

Resolving patch:
diff --git a/meinberlin/apps/bplan/management/commands/bplan_auto_archive.py b/meinberlin/apps/bplan/management/commands/bplan_auto_archive.py
--- a/meinberlin/apps/bplan/management/commands/bplan_auto_archive.py
+++ b/meinberlin/apps/bplan/management/commands/bplan_auto_archive.py
@@ -14,7 +14,9 @@ def handle(self, *args, **options):
         for bplan in bplans:
             if bplan.has_finished and not bplan.is_archived:
                 bplan.is_archived = True
-                bplan.save()
+                bplan.save(
+                    update_fields=['is_archived']
+                )
                 self.stdout.write('Archived bplan {}.'.format(bplan.name))
 
         # Delete statements of archived projects
diff --git a/meinberlin/apps/bplan/signals.py b/meinberlin/apps/bplan/signals.py
--- a/meinberlin/apps/bplan/signals.py
+++ b/meinberlin/apps/bplan/signals.py
@@ -10,7 +10,8 @@
 @receiver(post_save, sender=Bplan)
 def get_location(sender, instance, update_fields, **kwargs):
     if instance.identifier and (not update_fields or
-                                'point' not in update_fields):
+                                ('point' not in update_fields and
+                                 'is_archived' not in update_fields)):
         tasks.get_location_information(instance.pk)
 
 
@@ -25,5 +26,6 @@ def send_notification(sender, instance, created, **kwargs):
 
 @receiver(post_save, sender=Bplan)
 def send_update(sender, instance, update_fields, **kwargs):
-    if not update_fields or 'point' not in update_fields:
+    if (not update_fields or ('point' not in update_fields and
+                              'is_archived' not in update_fields)):
         emails.OfficeWorkerUpdateConfirmation.send(instance)


Test patch: