示例#1
0
    def post(self, key):
        viewed_user = ndb.Key(urlsafe=key).get()

        if self.request.get('delete') == 'delete':
            viewed_user.key.delete()
            self.redirect('/users')
            return

        viewed_user.name = self.request.get('name') or 'Unknown'
        viewed_user.email = self.request.get('email')
        viewed_user.level = integers.to_integer(self.request.get('level'), 1)

        if not EMAIL_REGEX.match(viewed_user.email):
            template.send(
                self, 'user.html', {
                    'title': 'User: '******'viewed_user': viewed_user,
                    'message': 'Please enter a valid email address.'
                })
            return

        viewed_user.put()

        template.send(self, 'user.html', {
            'title': 'User: '******'viewed_user': viewed_user
        })
示例#2
0
    def post(self, key):
        viewed_user = ndb.Key(urlsafe=key).get()

        if self.request.get('delete') == 'delete':
            viewed_user.key.delete()
            self.redirect('/users')
            return

        viewed_user.name = self.request.get('name') or 'Unknown'
        viewed_user.email = self.request.get('email')
        viewed_user.level = integers.to_integer(self.request.get('level'), 1)

        if not EMAIL_REGEX.match(viewed_user.email):
            template.send(self, 'user.html', {
                'title': 'User: '******'viewed_user': viewed_user,
                'message': 'Please enter a valid email address.'
            })
            return

        viewed_user.put()

        template.send(self, 'user.html', {
            'title': 'User: '******'viewed_user': viewed_user
        })
示例#3
0
 def get(self):
     template.send(self, 'user.html', {
         'title': 'New User',
         'viewed_user': {
             'new': True
         }
     })
示例#4
0
    def get(self, serial_number):
        try:
            values = spreadsheets.get_values(
                'Database!A2:A',
                service,
                decorator
            )

            blazer = None
            for i, row in enumerate(values):
                if not blazer and row[0] == serial_number:
                    blazer_row = i + 2
                    blazer_range = 'A%d:H%d' % (blazer_row, blazer_row)
                    blazer_data = spreadsheets.get_values(
                        blazer_range,
                        service,
                        decorator,
                        defaultValue=None
                    )

                    if blazer_data:
                        blazer = create_blazer(blazer_data[0])

            template.send(self, 'blazer.html', {
                'title': 'Blazer: ' + serial_number,
                'blazer': blazer
            })
        except client.AccessTokenRefreshError:
            self.redirect('/')
示例#5
0
 def get(self):
     template.send(self, 'user.html', {
         'title': 'New User',
         'viewed_user': {
             'new': True
         }
     })
示例#6
0
    def get(self):
        curr_user = user.get_user()
        loginUrl, logoutUrl = user.create_login_urls(self.request.path)

        if not curr_user:
            # exit early if logged out
            template.send(self, 'logout.html', {
                'title': 'Home',
                'loginUrl': loginUrl,
                'user': None
            })
            return

        template.send(self, 'home.html', {'title': 'Home'})
示例#7
0
    def get(self):
        curr_user = user.get_user()
        loginUrl, logoutUrl = user.create_login_urls(self.request.path)

        if not curr_user:
            # exit early if logged out
            template.send(self, 'logout.html', {
                'title': 'Home',
                'loginUrl': loginUrl,
                'user': None
            })
            return

        template.send(self, 'home.html', {
            'title': 'Home'
        })
示例#8
0
    def get(self):
        try:
            values = spreadsheets.get_values('Database!A2:D', service,
                                             decorator)

            blazers = []
            for row in values:
                if row[3] == 'Yes':
                    blazers.append(create_blazer(row))

            template.send(self, 'listings.html', {
                'title': 'Loaned Blazers',
                'blazers': blazers
            })
        except client.AccessTokenRefreshError:
            self.redirect('/')
示例#9
0
    def get(self):
    	events_query = ARCHIVES_QUERY.bind(date.get_date())

        cursor = Cursor(urlsafe=self.request.get('cursor'))
        events, next_cursor, more = events_query.fetch_page(25, start_cursor=cursor)

        next_link = None
        if more and next_cursor:
            next_link = next_cursor.urlsafe()

        template.send(self, 'events.html', {
            'title': 'Archives',
            'events': events,
            'url': 'archives',
            'next': next_link
        })
示例#10
0
    def get(self):
        try:
            values = spreadsheets.get_values(
                'Database!A2:D',
                service,
                decorator
            )

            blazers = []
            for row in values:
                if row[3] == 'Yes':
                    blazers.append(create_blazer(row))

            template.send(self, 'listings.html', {
                'title': 'Loaned Blazers',
                'blazers': blazers
            })
        except client.AccessTokenRefreshError:
            self.redirect('/')
示例#11
0
    def post(self):
        info = {
            'name': self.request.get('name') or 'Unknown',
            'email': self.request.get('email'),
            'level': integers.to_integer(self.request.get('level'), 1)
        }

        if not EMAIL_REGEX.match(info['email']):
            info['new'] = True
            template.send(self, 'user.html', {
                'title': 'New User',
                'viewed_user': info,
                'message': 'Please enter a valid email address.'
            })
            return

        key = User(**info).put()

        self.redirect('/users/' + key.urlsafe())
示例#12
0
    def post(self):
        info = {
            'name': self.request.get('name') or 'Unknown',
            'email': self.request.get('email'),
            'level': integers.to_integer(self.request.get('level'), 1)
        }

        if not EMAIL_REGEX.match(info['email']):
            info['new'] = True
            template.send(
                self, 'user.html', {
                    'title': 'New User',
                    'viewed_user': info,
                    'message': 'Please enter a valid email address.'
                })
            return

        key = User(**info).put()

        self.redirect('/users/' + key.urlsafe())
示例#13
0
    def get(self, serial_number):
        try:
            values = spreadsheets.get_values('Database!A2:A', service,
                                             decorator)

            blazer = None
            for i, row in enumerate(values):
                if not blazer and row[0] == serial_number:
                    blazer_row = i + 2
                    blazer_range = 'A%d:H%d' % (blazer_row, blazer_row)
                    blazer_data = spreadsheets.get_values(blazer_range,
                                                          service,
                                                          decorator,
                                                          defaultValue=None)

                    if blazer_data:
                        blazer = create_blazer(blazer_data[0])

            template.send(self, 'blazer.html', {
                'title': 'Blazer: ' + serial_number,
                'blazer': blazer
            })
        except client.AccessTokenRefreshError:
            self.redirect('/')
示例#14
0
文件: home.py 项目: vrmc/420blazeit
    def get(self):
        curr_user = user.get_user()

        if not curr_user:
            # exit early if logged out
            template.send(self, 'logout.html', {'title': 'Home', 'user': None})
            return
        elif curr_user.level == 0:
            # not a vjc email
            template.send(self, 'logout.html', {'title': 'Unauthorised'})
        else:
            template.send(self, 'home.html', {'title': 'Home'})
示例#15
0
 def get(self):
     template.send(self, 'users.html', {
         'title': 'Users',
         'users': USERS_QUERY.fetch(),
     })
示例#16
0
 def get(self, key):
     viewed_user = ndb.Key(urlsafe=key).get()
     template.send(self, 'user.html', {
         'title': 'User: '******'viewed_user': viewed_user
     })
示例#17
0
 def get(self, key):
     viewed_user = ndb.Key(urlsafe=key).get()
     template.send(self, 'user.html', {
         'title': 'User: '******'viewed_user': viewed_user
     })
示例#18
0
 def get(self):
     template.send(self, 'users.html', {
         'title': 'Users',
         'users': USERS_QUERY.fetch(),
     })
示例#19
0
 def get(self, key):
     event = ndb.Key(urlsafe=key).get()
     template.send(self, 'event.html', {
         'title': 'Event: ' + event.name,
         'event': event
     })