Beispiel #1
0
    def get(self):
        # don't bother starting to nag before Tuesday 10am
        today = datetime.today()
        email = self.request.get('email', False)
        priority = None
        # sun-tue only check high priority
        if today.weekday() in (6, 0, 1) and not email:
            logging.debug('Only checking high priority invites.')
            priority = 'Insist'

        status = self.request.get('status', None)
        gn = Gamenight.schedule(status=status, priority=priority)
        if gn and gn.status == 'Yes' or not email:
            logging.debug('No need to nag.')
            self.redirect('/')
            return

        # saturday afternoon just give up and say no
        if today.weekday() == 5 and today.hour > 16:
            logging.debug('Giving up on scheduling this week.')
            gn = Gamenight.schedule(status='No', date=today.date())
            self.redirect('/')
            return

        logging.debug('Sending out email template: %s', email)
        subjects = { 'first': 'Want to host gamenight?',
                     'second': 'Still looking to find a host for gamenight this week!' }
        bodies = {'first': "Seems that no one has offered to host gamenight this week. " +
                           "Want to host? Go to http://%(url)s/invite!" ,
                  'second': "We still haven't had anyone volunteer to host gamenight this week. " +
                            "For now, the site will show '%(status)s', but if you'd like to host, " +
                            "please go to http://%(url)s/invite to have people come over.  ",
                 }

        footer = ("\nThanks!\n\n(You asked to get these emails if no one is hosting gamenight. " +
                  "If you want to stop getting these, go to http://%(url)s/profile and uncheck " +
                  "the 'nag emails' option.)")

        message = mail.EmailMessage()
        message.sender = 'Gamenight <%s>' % config.get('sender')
        message.to = message.sender
        message.subject = subjects[email]
        message.body = (bodies[email] + footer) % { 'url': config.get('url', "TBD"), 'status': status }

        message.bcc = [u.key.id() for u in User.query(User.nag==True).fetch()]
        logging.info('Sending nag email to %r', message.to)
        message.send()

        self.redirect('/')
Beispiel #2
0
    def get(self):
        # don't bother starting to nag before Tuesday 10am
        today = datetime.today()
        email = self.request.get('email', False)
        priority = None
        # sun-tue only check high priority
        if today.weekday() in (6, 0, 1) and not email:
            logging.debug('Only checking high priority invites.')
            priority = 'Insist'

        status = self.request.get('status', None)
        gn = Gamenight.schedule(status=status, priority=priority)
        if gn and gn.status == 'Yes' or not email:
            logging.debug('No need to nag.')
            self.redirect('/')
            return

        # saturday afternoon just give up and say no
        if today.weekday() == 5 and today.hour > 16:
            logging.debug('Giving up on scheduling this week.')
            gn = Gamenight.schedule(status='No', date=today.date())
            self.redirect('/')
            return

        logging.debug('Sending out email template: %s', email)
        subjects = { 'first': 'Want to host gamenight?',
                     'second': 'Still looking to find a host for gamenight this week!' }
        bodies = {'first': "Seems that no one has offered to host gamenight this week. " +
                           "Want to host? Go to http://%(url)s/invite!" ,
                  'second': "We still haven't had anyone volunteer to host gamenight this week. " +
                            "For now, the site will show '%(status)s', but if you'd like to host, " +
                            "please go to http://%(url)s/invite to have people come over.  ",
                 }

        footer = ("\nThanks!\n\n(You asked to get these emails if no one is hosting gamenight. " +
                  "If you want to stop getting these, go to http://%(url)s/profile and uncheck " +
                  "the 'nag emails' option.)")

        message = mail.EmailMessage()
        message.sender = 'Gamenight <%s>' % config.get('sender')
        message.to = message.sender
        message.subject = subjects[email]
        message.body = (bodies[email] + footer) % { 'url': config.get('url', "TBD"), 'status': status }

        message.bcc = [u.key.id() for u in User.query(User.nag==True).fetch()]
        logging.info('Sending nag email to %r', message.to)
        message.send()

        self.redirect('/')
Beispiel #3
0
    def get(self, template_values={}, msg=None, error=None, profile=None):
        user = User.get(users.get_current_user())

        template_values.update({
            'user': user,
            'msg': msg,
            'error': error,
            'logout': users.create_logout_url('/'),
        })

        template_values['profile'] = user

        if user.superuser:
            template_values['users'] = User.query().fetch()
            if profile:
                template_values['profile'] = User.lookup(profile)

                if not profile:
                    template_values['profile'] = user
                    template_values['error'] = "Couldn't find user %s" % profile


        template = JINJA_ENVIRONMNT.get_template('profile.html')
        self.response.write(template.render(template_values))
Beispiel #4
0
    def get(self, template_values={}, msg=None, error=None, profile=None):
        user = User.get(users.get_current_user())

        template_values.update({
            'user': user,
            'msg': msg,
            'error': error,
            'logout': users.create_logout_url('/'),
        })

        template_values['profile'] = user

        if user.superuser:
            template_values['users'] = User.query().fetch()
            if profile:
                template_values['profile'] = User.lookup(profile)

                if not profile:
                    template_values['profile'] = user
                    template_values['error'] = "Couldn't find user %s" % profile


        template = JINJA_ENVIRONMNT.get_template('profile.html')
        self.response.write(template.render(template_values))