Esempio n. 1
0
    def handle(self, *args, **options):
        """
        For every summary in the summary table, create a new copy and set dates
        to new interval
        """

        for summary in Summary.objects.filter(mail_sent=True).all():
            print "duplicating summary id {}".format(summary.id)
            duplicate = Summary()
            duplicate.dateStart = date.today() - timedelta(days=14)
            duplicate.dateEnd = date.today()
            duplicate.introduction = summary.introduction
            duplicate.project = summary.project
            duplicate.traffic_advice = summary.traffic_advice
            duplicate.availability_advice = summary.availability_advice
            duplicate.facebook_advice = summary.facebook_advice
            duplicate.mailchimp_advice = summary.mailchimp_advice
            duplicate.conversion_advice = summary.conversion_advice
            duplicate.save()
Esempio n. 2
0
    def get_context_data(self, **kwargs):
        context = super(self.__class__, self).get_context_data(**kwargs)
        if self.extra_context is not None:
            for key, value in self.extra_context.items():
                if callable(value):
                    context[key] = value()
                else:
                    context[key] = value

        # get testproject
        project_id = self.kwargs["pk"]
        project = Project.objects.get(id=project_id)
        mock_summary = Summary()
        mock_summary.project = project
        mock_summary.dateStart = datetime.date.today() - timedelta(days=15)
        mock_summary.dateEnd = datetime.date.today() - timedelta(days=1)
        mock_summary.introduction = """Nam quis nisi eu nulla accumsan congue nec nec enim. Pellentesque sit amet lorem ut augue lobortis iaculis. In elementum suscipit mauris elementum tincidunt. Curabitur pellentesque ullamcorper metus quis venenatis. Nunc urna ipsum, faucibus eu ex sit amet, pellentesque tincidunt est. Sed ullamcorper ipsum non iaculis consectetur. Cras sit amet leo vitae enim viverra auctor sit amet at mi. Proin non arcu eu ligula pharetra lacinia. Donec at metus eget tellus efficitur vulputate. Sed dignissim metus velit, et sollicitudin ex bibendum auctor. Integer ornare felis ante. Sed sit amet facilisis nulla. Nam dapibus maximus dignissim."""
        mock_summary.facebook_advice = mock_summary.introduction
        mock_summary.availability_advice = mock_summary.introduction
        mock_summary.traffic_advice = mock_summary.introduction
        mock_summary.conversion_advice = mock_summary.introduction
        fill_context(context, mock_summary)

        return context