コード例 #1
0
ファイル: models.py プロジェクト: repodevs/bluebottle
    def status_changed(self, old_status, new_status):

        status_complete = ProjectPhase.objects.get(slug="done-complete")
        status_incomplete = ProjectPhase.objects.get(slug="done-incomplete")

        if new_status == status_complete:
            mail_project_complete(self)
        if new_status == status_incomplete:
            mail_project_incomplete(self)

        data = {
            "Project": self.title,
            "Owner": self.owner.email,
            "old_status": old_status.name,
            "new_status": new_status.name
        }

        if old_status.slug in ('plan-new',
                               'plan-submitted',
                               'plan-needs-work',
                               'voting',
                               'voting-done',
                               'campaign') and new_status.slug in ('done-complete',
                                                                   'done-incomplete',
                                                                   'closed'):

            bb_track("Project Completed", data)
コード例 #2
0
ファイル: models.py プロジェクト: repodevs/bluebottle
    def deadline_reached(self):
        # BB-3616 "Funding projects should not look at (in)complete tasks for their status."
        from bluebottle.utils.model_dispatcher import get_task_model

        TASK_MODEL = get_task_model()

        if self.is_funding:
            if self.amount_donated >= self.amount_asked:
                self.status = ProjectPhase.objects.get(slug="done-complete")
            elif self.amount_donated <= 20 or not self.campaign_started:
                self.status = ProjectPhase.objects.get(slug="closed")
            else:
                self.status = ProjectPhase.objects.get(slug="done-incomplete")
        else:
            if self.task_set.filter(
                    status__in=[TASK_MODEL.TaskStatuses.in_progress,
                                TASK_MODEL.TaskStatuses.open]).count() > 0:
                self.status = ProjectPhase.objects.get(slug="done-incomplete")
            else:
                self.status = ProjectPhase.objects.get(slug="done-complete")
        self.campaign_ended = now()
        self.save()

        data = {
            "Project": self.title,
            "Author": self.owner.username
        }

        bb_track("Project Deadline Reached", data)
コード例 #3
0
    def status_changed(self, old_status, new_status):
        status_complete = ProjectPhase.objects.get(slug="done-complete")
        status_incomplete = ProjectPhase.objects.get(slug="done-incomplete")

        if new_status == status_complete:
            mail_project_complete(self)
        if new_status == status_incomplete:
            mail_project_incomplete(self)

        data = {
            "Project": self.title,
            "Owner": self.owner.email,
            "old_status": old_status.slug,
            "new_status": new_status.slug
        }

        if old_status.slug in ('plan-new',
                               'plan-submitted',
                               'plan-needs-work',
                               'voting',
                               'voting-done',
                               'campaign') and new_status.slug in ('done-complete',
                                                                   'done-incomplete',
                                                                   'closed'):
            bb_track("Project Completed", data)
コード例 #4
0
ファイル: models.py プロジェクト: jfterpstra/bluebottle
    def deadline_reached(self):
        # BB-3616 "Funding projects should not look at (in)complete tasks for their status."
        if self.is_funding:
            if self.amount_donated >= self.amount_asked:
                self.status = ProjectPhase.objects.get(slug="done-complete")
            elif self.amount_donated.amount <= 20 or not self.campaign_started:
                self.status = ProjectPhase.objects.get(slug="closed")
            else:
                self.status = ProjectPhase.objects.get(slug="done-incomplete")
        else:
            if self.task_set.filter(
                    status__in=[Task.TaskStatuses.in_progress,
                                Task.TaskStatuses.open,
                                Task.TaskStatuses.closed]).count() > 0:
                self.status = ProjectPhase.objects.get(slug="done-incomplete")
            else:
                self.status = ProjectPhase.objects.get(slug="done-complete")
        self.campaign_ended = now()
        self.save()

        data = {
            "Project": self.title,
            "Author": self.owner.username
        }

        bb_track("Project Deadline Reached", data)
コード例 #5
0
    def deadline_reached(self):
        # BB-3616 "Funding projects should not look at (in)complete tasks for their status."
        self.update_status_after_deadline()
        self.campaign_ended = now()
        self.save()

        data = {
            "Project": self.title,
            "Author": self.owner.username
        }

        bb_track("Project Deadline Reached", data)
コード例 #6
0
ファイル: models.py プロジェクト: repodevs/bluebottle
    def deadline_reached(self):
        """ The task deadline has been reached. Set it to realised and notify the
            owner """
        # send "The deadline of your task" - mail

        self.status = 'realized'
        self.save()

        data = {
            "Task": self.title,
            "Author": self.author.username
        }
        bb_track("Task Deadline Reached", data)
コード例 #7
0
ファイル: models.py プロジェクト: jfterpstra/bluebottle
    def status_changed(self, oldstate, newstate):
        """ called by post_save signal handler, if status changed """
        # confirm everything with task owner

        if oldstate in ("in progress", "open", "closed") and newstate == "realized":
            self.project.check_task_status()

            with TenantLanguage(self.author.primary_language):
                subject = _("The status of your task '{0}' is set to realized").format(self.title)

            send_mail(
                template_name="tasks/mails/task_status_realized.mail",
                subject=subject,
                title=self.title,
                to=self.author,
                site=tenant_url(),
                link='/go/tasks/{0}'.format(self.id)
            )

        if oldstate in ("in progress", "open") and newstate == "closed":

            with TenantLanguage(self.author.primary_language):
                subject = _("The status of your task '{0}' is set to closed").format(self.title)

            send_mail(
                template_name="tasks/mails/task_status_closed.mail",
                subject=subject,
                title=self.title,
                to=self.author,
                site=tenant_url(),
                link='/go/tasks/{0}'.format(self.id)
            )

        if oldstate in ("in progress", "open") and newstate in ("realized", "closed"):
            data = {
                "Task": self.title,
                "Author": self.author.username,
                "Old status": oldstate,
                "New status": newstate
            }

            bb_track("Task Completed", data)
コード例 #8
0
ファイル: test_unit.py プロジェクト: raux/bluebottle
 def test_tracking_title_with_data(self, mock_track):
     bb_track("Test Event", {'bla': 'bla'})
     mock_track.assert_called_with(None, "Test Event", {'bla': 'bla'})
コード例 #9
0
ファイル: test_unit.py プロジェクト: raux/bluebottle
 def test_tracking_title(self, mock_track):
     bb_track("Test Event without data")
     mock_track.assert_called_with(None, "Test Event without data", {})
コード例 #10
0
ファイル: test_unit.py プロジェクト: raux/bluebottle
 def test_tracking_no_key(self, mock_track):
     result = bb_track("Test event")
     self.assertEquals(result, False)
コード例 #11
0
ファイル: test_unit.py プロジェクト: raux/bluebottle
 def test_tracking_no_title(self, mock_track):
     result = bb_track()
     self.assertEquals(result, False)