Exemplo n.º 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
        })
Exemplo n.º 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
        })
Exemplo n.º 3
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())
Exemplo n.º 4
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())