예제 #1
0
    def post(self):
        if len(self.request.POST) == 4 and 'handle' in self.request.POST \
                and 'real_name' in self.request.POST \
                and 'email' in self.request.POST \
                and 'bio' in self.request.POST:

            handle = self.request.POST.getall('handle')[0]
            template_dict = {}
            hacker = Hacker.get_current_hacker()
            other = Hacker.gql('WHERE handle = :1', handle).get()

            if (not handle or len(handle) > 12
                    or any(l not in self.valid_letters for l in handle)):
                template_dict['error'] = 'Pick something sensible, you moron.'

            elif other and other.user_id != hacker.user_id:
                template_dict['error'] = 'Sorry, already taken.'

            elif handle.lower() in self.banned_names:
                template_dict['error'] = self.banned_names[handle]

            else:
                real_name = self.request.POST.getall('real_name')[0]
                if real_name:
                    hacker.real_name = real_name
                email = self.request.POST.getall('email')[0]
                if email:
                    hacker.email = email
                bio = self.request.POST.getall('bio')[0]
                if bio:
                    hacker.bio = bio
                hacker.handle = handle
                hacker.save()
                template_dict['error'] = 'Profile updated'
            self.render_template('account', template_dict=template_dict)
예제 #2
0
파일: handlers.py 프로젝트: Ziyad/man-up
 def post(self):
     if len(self.request.POST) == 4 and 'handle' in self.request.POST \
             and 'real_name' in self.request.POST \
             and 'email' in self.request.POST \
             and 'bio' in self.request.POST:
         
         handle = self.request.POST.getall('handle')[0]
         template_dict = {}
         hacker = Hacker.get_current_hacker()
         other = Hacker.gql('WHERE handle = :1', handle).get()
         
         if (not handle or len(handle) > 12 or
             any(l not in self.valid_letters for l in handle)):
             template_dict['error'] = 'Pick something sensible, you moron.'
         
         elif other and other.user_id != hacker.user_id:
             template_dict['error'] = 'Sorry, already taken.'
         
         elif handle.lower() in self.banned_names:
             template_dict['error'] = self.banned_names[handle]
         
         else:
             real_name = self.request.POST.getall('real_name')[0]
             if real_name:
                 hacker.real_name = real_name
             email = self.request.POST.getall('email')[0]
             if email:
                 hacker.email = email
             bio = self.request.POST.getall('bio')[0]
             if bio:
                 hacker.bio = bio
             hacker.handle = handle
             hacker.save()
             template_dict['error'] = 'Profile updated'
         self.render_template('account', template_dict=template_dict)
예제 #3
0
 def get(self):
     if 'url' in self.request.GET:
         hacker = Hacker.get_current_hacker()
         if hacker.handle.isdigit() and len(hacker.handle) == 21:
             self.redirect('/account')
         else:
             self.redirect(self.request.GET.getall('url')[0])
     else:
         self.redirect('/')
예제 #4
0
파일: handlers.py 프로젝트: Ziyad/man-up
 def get(self):
     if 'url' in self.request.GET:
         hacker = Hacker.get_current_hacker()
         if hacker.handle.isdigit() and len(hacker.handle) == 21:
             self.redirect('/account')
         else:
             self.redirect(self.request.GET.getall('url')[0])
     else:
         self.redirect('/')
예제 #5
0
파일: handlers.py 프로젝트: Ziyad/man-up
 def post(self):
     post = self.request.POST
     if len(post) == 2 and 'badge' in post and 'proof' in post:
         body = 'Hacker: %s\nBadge: %s\nProof:\n%s' % (
             Hacker.get_current_hacker().handle, post['badge'], 
             post['proof'])
         send_mail(
             sender='*****@*****.**',
             to='*****@*****.**',
             subject='Badge application',
             body=body)
         self.render_template('badge_application', template_dict={'message':
             'Application submitted. It will be reviewed as soon as possible.'})
예제 #6
0
 def post(self):
     post = self.request.POST
     if len(post) == 2 and 'badge' in post and 'proof' in post:
         body = 'Hacker: %s\nBadge: %s\nProof:\n%s' % (
             Hacker.get_current_hacker().handle, post['badge'],
             post['proof'])
         send_mail(sender='*****@*****.**',
                   to='*****@*****.**',
                   subject='Badge application',
                   body=body)
         self.render_template(
             'badge_application',
             template_dict={
                 'message':
                 'Application submitted. It will be reviewed as soon as possible.'
             })
예제 #7
0
    def render_template(self, template_name, template_dict=None):
        next_meeting = Meeting.get_next_meeting()
        if next_meeting:
            tag_line = '%s: %s, %s' % (next_meeting.name,
                                       next_meeting.start_date,
                                       next_meeting.location)
        else:
            tag_line = 'Evening Hack: 14/4/2011 5pm LF15'

        if template_dict is None:
            template_dict = {}

        user = Hacker.get_current_hacker()

        if user:
            if self.login_required:
                redirect_target = '/'
            else:
                redirect_target = self.request.path
            url_creator = users.create_logout_url
        else:
            redirect_target = '/login?url=%s' % self.request.path
            url_creator = users.create_login_url

        defaults = {
            'user': user,
            'log_url': url_creator(redirect_target),
            'tag_line': tag_line,
            'title': self.title
        }

        for key in defaults:
            if key not in template_dict:
                template_dict[key] = defaults[key]

        template_path = get_path(
            os.path.join('templates', '%s.html' % template_name))
        self.response.out.write(template.render(template_path, template_dict))
예제 #8
0
파일: handlers.py 프로젝트: Ziyad/man-up
 def render_template(self, template_name, template_dict=None):
     next_meeting = Meeting.get_next_meeting()
     if next_meeting:
         tag_line = '%s: %s, %s' % (next_meeting.name, next_meeting.start_date, next_meeting.location)
     else:
         tag_line = 'Evening Hack: 14/4/2011 5pm LF15'
 
     if template_dict is None:
         template_dict = {}
     
     user = Hacker.get_current_hacker()
     
     if user:
         if self.login_required:
             redirect_target = '/'
         else:
             redirect_target = self.request.path
         url_creator = users.create_logout_url
     else:
         redirect_target = '/login?url=%s' % self.request.path
         url_creator = users.create_login_url
         
     defaults = {
         'user': user,
         'log_url': url_creator(redirect_target),
         'tag_line': tag_line,
         'title': self.title
     }
     
     for key in defaults:
         if key not in template_dict:
             template_dict[key] = defaults[key]
     
     template_path = get_path(
         os.path.join('templates', '%s.html' % template_name))
     self.response.out.write(
         template.render(template_path, template_dict))