コード例 #1
0
ファイル: profile.py プロジェクト: Sagelt/dungeon-world-codex
 def get(self, profile_id=None):
   """HTML GET handler.
   
   Check the query parameters for the ID of the profile to be displayed.
   If found, display the user. Otherwise display current user"""
   
   template_values = self.build_template_values()
   
   if profile_id and template_values[handlers.base.PROFILE_KEY] and int(profile_id) == template_values[handlers.base.PROFILE_KEY].key().id():
     template_values['viewed_profile'] = template_values[handlers.base.PROFILE_KEY]
   elif profile_id:
     template_values['viewed_profile'] = Profile.get_by_id(int(profile_id))
   elif template_values[handlers.base.PROFILE_KEY]:
     return self.redirect(self.uri_for("profile", profile_id=template_values[handlers.base.PROFILE_KEY].key().id()))
   else:
     return self.forbidden()
   
   favorites = Vote.all().filter("voter = ", template_values['viewed_profile']).filter("is_up = ", True).fetch(1)
   if favorites:
     template_values['recent_up_monster'] = favorites[0].monster
     
   created =   Monster.get_recent(1, creator=template_values['viewed_profile'], user=template_values[handlers.base.PROFILE_KEY])
   if created:
     template_values['recent_monster'] = created[0]
   template = configuration.site.jinja_environment.get_template('profile/view.html')
   return self.response.write(template.render(template_values))
コード例 #2
0
ファイル: home.py プロジェクト: Sagelt/dungeon-world-codex
    def get(self):
        """HTML GET handler.
    
    Renders a response to a GET. Queries monsters to feature and renders
    them to the index.html template. Does not accept any query parameters"""

        template_values = self.build_template_values()
        template_values["popular_monsters"] = Monster.get_top_rated(5, user=template_values[handlers.base.PROFILE_KEY])
        template_values["recent_monsters"] = Monster.get_recent(5, user=template_values[handlers.base.PROFILE_KEY])

        template = configuration.site.jinja_environment.get_template("index.html")
        self.response.write(template.render(template_values))
コード例 #3
0
ファイル: profile.py プロジェクト: Sagelt/dungeon-world-codex
 def get(self, profile_id=None):
   """HTML GET handler.
   
   Renders a response to a GET. Queries monsters to feature and renders
   them. Easy enough, right?"""
   
   template_values = self.build_template_values()
   skip = int(self.request.get("skip", default_value=0))
   creator = Profile.get_by_id(int(profile_id))
   template_values['creator'] = creator
   template_values['monsters'] = Monster.get_recent(
     10,
     creator=creator,
     user=template_values[handlers.base.PROFILE_KEY],
     skip=skip)
   
   if len(template_values['monsters']) >= 10:
     template_values['next'] = str(self.uri_for('profile.monster.all', profile_id=profile_id))+"?skip="+str(skip+10)
     
   if skip >= 10:
     template_values['prev'] = str(self.uri_for('profile.monster.all', profile_id=profile_id))+"?skip="+str(skip-10)
  
   template = configuration.site.jinja_environment.get_template('monster/all.html')
   self.response.write(template.render(template_values))