Exemplo n.º 1
0
 def post(self, user_token):
   team = Team.all().filter('user_token =', user_token).get()
   if team is None:
     # just make sure this pledge exists
     user_info = config_NOCOMMIT.pledge_service.loadPledgeInfo(user_token)
     if user_info is None:
       return self.notfound()
   form = TeamForm(self.request.POST, team)
   if not form.validate():
     return self.render_template("new_from_pledge.html", form=form)
   if team is None:
     gravatar = "https://secure.gravatar.com/avatar/%s?%s" % (
       hashlib.md5(user_info['email'].lower()).hexdigest(),
       urllib.urlencode({'s': str('120')}))
     team = Team.create(title=form.title.data,
                        description=form.description.data,
                        zip_code=form.zip_code.data,
                        user_token=user_token,
                        gravatar=gravatar)
   else:
     form.populate_obj(team)
   self.add_to_user(team)
   team.primary_slug = Slug.new(team)  
   try:
     result = config_NOCOMMIT.pledge_service.updateMailchimp(team) 
   except Exception as e:
     logging.error('Exception updating mailChimp: ' + str(e))
     logging.info(traceback.format_exc())
   team.put()
   if self.logged_in:
     return self.redirect("/t/%s" % team.primary_slug)
   return self.redirect("/dashboard/add_admin_from_pledge/%s" % user_token)
Exemplo n.º 2
0
 def post(self, user_token):
     team = Team.all().filter('user_token =', user_token).get()
     if team is None:
         # just make sure this pledge exists
         user_info = config_NOCOMMIT.pledge_service.loadPledgeInfo(
             user_token)
         if user_info is None:
             return self.notfound()
     form = TeamForm(self.request.POST, team)
     if not form.validate():
         return self.render_template("new_from_pledge.html", form=form)
     if team is None:
         gravatar = "https://secure.gravatar.com/avatar/%s?%s" % (
             hashlib.md5(user_info['email'].lower()).hexdigest(),
             urllib.urlencode({'s': str('120')}))
         team = Team.create(title=form.title.data,
                            description=form.description.data,
                            zip_code=form.zip_code.data,
                            user_token=user_token,
                            gravatar=gravatar)
     else:
         form.populate_obj(team)
     self.add_to_user(team)
     team.primary_slug = Slug.new(team)
     try:
         result = config_NOCOMMIT.pledge_service.updateMailchimp(team)
     except Exception as e:
         logging.error('Exception updating mailChimp: ' + str(e))
         logging.info(traceback.format_exc())
     team.put()
     if self.logged_in:
         return self.redirect("/t/%s" % team.primary_slug)
     return self.redirect("/dashboard/add_admin_from_pledge/%s" %
                          user_token)
Exemplo n.º 3
0
 def validate(self, slug):
   s = Slug.get_by_key_name(slug)
   if s is None:
     self.notfound()
     return None, False, False
   team = s.team
   if team is None:
     self.notfound()
     return None, False, False
   primary = True
   if team.primary_slug and team.primary_slug != slug:
     primary = False
   is_admin = False
   if self.logged_in:
     if isUserAdmin(self.current_user["user_id"], team):
       is_admin = True
   return team, primary, is_admin
Exemplo n.º 4
0
 def validate(self, slug):
     s = Slug.get_by_key_name(slug)
     if s is None:
         self.notfound()
         return None, False, False
     team = s.team
     if team is None:
         self.notfound()
         return None, False, False
     primary = True
     if team.primary_slug and team.primary_slug != slug:
         primary = False
     is_admin = False
     if self.logged_in:
         if isUserAdmin(self.current_user["user_id"], team):
             is_admin = True
     return team, primary, is_admin
Exemplo n.º 5
0
 def post(self, slug):
   team, _, is_admin = self.validate(slug)
   if team is None:
     return
   if not is_admin:
     return self.redirect("/t/%s" % team.primary_slug)
   form = TeamForm(self.request.POST, team)
   if not form.validate():
     return self.render_template("edit_team.html", form=form)
   form.populate_obj(team)
   team.primary_slug = Slug.new(team)
   try:
     result = config_NOCOMMIT.pledge_service.updateMailchimp(team) 
   except Exception as e:
     logging.error('Exception updating mailChimp: ' + str(e))
     logging.info(traceback.format_exc())
 
   team.put()
   self.redirect("/t/%s" % team.primary_slug)
Exemplo n.º 6
0
    def post(self, slug):
        team, _, is_admin = self.validate(slug)
        if team is None:
            return
        if not is_admin:
            return self.redirect("/t/%s" % team.primary_slug)
        form = TeamForm(self.request.POST, team)
        if not form.validate():
            return self.render_template("edit_team.html", form=form)
        form.populate_obj(team)
        team.primary_slug = Slug.new(team)
        try:
            result = config_NOCOMMIT.pledge_service.updateMailchimp(team)
        except Exception as e:
            logging.error('Exception updating mailChimp: ' + str(e))
            logging.info(traceback.format_exc())

        team.put()
        self.redirect("/t/%s" % team.primary_slug)
Exemplo n.º 7
0
  def post(self):
    form = TeamForm(self.request.POST)
    if not form.validate():
      return self.render_template("new_team.html", form=form)
    team = Team.create(title=form.title.data,
                       description=form.description.data,
                       goal_dollars=form.goal_dollars.data,
                       youtube_id=form.youtube_id.data,
                       zip_code=form.zip_code.data)
    # TODO: can i reference a team before putting it in other reference
    # properties? should check
    team.primary_slug = Slug.new(team)    
    try:
      result = config_NOCOMMIT.pledge_service.updateMailchimp(team) 
    except Exception as e:
      logging.error('Exception updating mailChimp: ' + str(e))
      logging.info(traceback.format_exc())

    team.put()
    makeUserAdmin(self.current_user["user_id"], team)
    return self.redirect("/t/%s" % team.primary_slug)
Exemplo n.º 8
0
    def post(self):
        form = TeamForm(self.request.POST)
        if not form.validate():
            return self.render_template("new_team.html", form=form)
        team = Team.create(title=form.title.data,
                           description=form.description.data,
                           goal_dollars=form.goal_dollars.data,
                           youtube_id=form.youtube_id.data,
                           zip_code=form.zip_code.data)
        # TODO: can i reference a team before putting it in other reference
        # properties? should check
        team.primary_slug = Slug.new(team)
        try:
            result = config_NOCOMMIT.pledge_service.updateMailchimp(team)
        except Exception as e:
            logging.error('Exception updating mailChimp: ' + str(e))
            logging.info(traceback.format_exc())

        team.put()
        makeUserAdmin(self.current_user["user_id"], team)
        return self.redirect("/t/%s" % team.primary_slug)
Exemplo n.º 9
0
def test_slug():
    slug = Slug(True, 'Jardin', 'jour')
    assert slug.rep() == '001\n\intslug[jour]{Jardin}'