Example #1
0
def recipe_list(request):
    logs = log_get()
    recipes = request.user.recipe_set.all() if request.user.is_authenticated(
    ) else []
    for recipe in recipes:
        recipe.log = logs.get(recipe.uid(), {})
    return render(request, "recipe/recipe_list.html", {'recipes': recipes})
Example #2
0
 def handle(self, *args, **kwargs):
     logs = log_get()
     for account in Account.objects.filter(
             pk=kwargs['account']
     ) if kwargs['account'] else Account.objects.all():
         for recipe in storage_list(account):
             if kwargs['recipe'] and kwargs['recipe'] != recipe.name:
                 continue  # skip all others if recipe specified
             recipe.log = logs.get(recipe.uid(), {})
             print recipe.filename_storage, recipe.uid(
             ), account.email, recipe.log.get('status'), recipe.log.get(
                 'time_ago')
Example #3
0
 def _get_log(self):
     if self._log is None: self._log = log_get(self.uid(), {})
     return self._log
Example #4
0
 def _get_log(self):
     if self._log is None: self._log = log_get(self.uid(), self.timezone)
     return self._log
Example #5
0
def view_storage_list(request):
    logs = log_get()
    recipes = list(storage_list(request.user))
    for recipe in recipes:
        recipe.log = logs.get(recipe.uid(), {})
    return render(request, "storage/storage_list.html", {'recipes': recipes})
Example #6
0
    def handle(self, *args, **kwargs):

        # loop through accounts
        for account in Account.objects.all():
            # if account is given only do that one
            if kwargs['email'] is None or account.email == kwargs['email']:
                print 'CHECKING: ', account.email

                status = False

                # start an email template
                email = EmailTemplate()
                email.segment_next()
                email.greeting(account.name)
                email.paragraph(EMAIL_PARAGRAPH)

                # pre fetch logs in one call
                logs = log_get()

                # loop through recipes
                rows = []
                for recipe in account.recipe_set.all():
                    recipe.log = logs.get(recipe.uid(), {})
                    rows.append([
                        recipe.name,
                        recipe.log.get('status'),
                        recipe.log.get('time_ago'),
                        'http://starthinker.corp.google.com/recipe/edit/%d/' %
                        recipe.pk
                    ])

                if rows:
                    email.segment_next()
                    email.header('Recipe Status')
                    email.table(RECIPE_SCHEMA, rows)
                    status = True

                # loop through storage
                rows = []
                for recipe in storage_list(account):
                    recipe.log = logs.get(recipe.uid(), {})
                    rows.append([
                        recipe.name,
                        recipe.log.get('status'),
                        recipe.log.get('time_ago'), recipe.link_storage
                    ])

                if rows:
                    email.segment_next()
                    email.header('Storage Status')
                    email.table(RECIPE_SCHEMA, rows)
                    status = True

                    #        # if at least one solution or recipe is running....
                    #        if status:
                    #
                    #          # show one random recipe
                    #          email.segment_next()
                    #          email.header('Featured Recipes')
                    #          email.paragraph('Each week we feature three recipes that could help your client or agency project.  This weeks featured recipe is...')
                    #
                    #          # script: card ( fetch random )
                    #          for s in sample(list(Script.get_scripts()), 3):
                    #            email.header(s.get_name())
                    #            email.paragraph(s.get_description())
                    #
                    #            # solution pitch
                    #            email.paragraph('Benefits', bold=True)
                    #            email.list(s.get_pitches())
                    #
                    #            # solution impact
                    #            email.table(IMPACT_SCHEMA, [(i[0], '%d%%' % i[1]) for i in s.get_impacts().items()])
                    #
                    #            email.table(DETAILS_SCHEMA, [
                    #              ('Requires', ', '.join([r[0] for r in s.get_requirements().items() if r[1]])),
                    #              ('Categories', ', '.join(s.get_categories())),
                    #              ('Authors', mailto(s.get_authors()))
                    #            ])
                    #
                    #            email.button('Launch %s' % s.get_name(), '%s/client/edit/' % settings.CONST_URL, big=True)
                    #
                    #            if s.get_open_source():
                    #              email.button('Avaliable As Open Source', s.get_open_source(), big=True)
                    #
                    #          # loop through links
                    #          email.segment_next()
                    #          email.header('Helpful Links')
                    #          email.paragraph('Reduce solution delivery to minutes and create custom solutions that exceed clients expectations with these helpful guides and tips.')
                    for h in HELP_LINKS:
                        email.section(h['name'], h['description'], None,
                                      h['button']['link'], h['button']['text'])

                    if kwargs['test']:
                        # write to STDOUT
                        print email.get_html()
                    else:
                        print 'EMAILING: ', account.email
                        # send message via email
                        project.initialize()
                        send_email('user', account.email, EMAIL_FROM, EMAIL_CC,
                                   EMAIL_SUBJECT, email.get_text(),
                                   email.get_html())
                        sleep(3)