コード例 #1
0
ファイル: club.py プロジェクト: cardmaster/makeclub
	def get(self, *args):
		if (isAccessible('', 'listClubs')):
			clubs = Club.all()
			vars = dict (clubs=Club.all(), cluburl=viewurlconf.path('')[:-1])
			if (isAccessible('', 'createClub')):
				nowdt = datetime.now()
				newslug = "newclb_%d%d%d%d%d%d%d" % (nowdt.year, nowdt.month, nowdt.day, nowdt.hour, nowdt.minute, nowdt.second, nowdt.microsecond)
				newcluburl = editurlconf.path(newslug) 
				vars['newcluburl'] = newcluburl
			self.response.out.write (render(self.template, vars, self.request.url) )
		else:
			errorPage( self.response,  "Not Accessible",   users.create_login_url(self.request.uri))
コード例 #2
0
ファイル: main.py プロジェクト: skitazaki/jleague-calendar
 def get(self):
     clubs = []
     for c in Club.all().filter('category IN', ("J1", "J2")):
         clubs.append(c)
     random.shuffle(clubs)
     params = {'clubs': clubs}
     t = JINJA2_ENV.get_template('club-list.html')
     self.response.out.write(t.render(params))
コード例 #3
0
ファイル: access.py プロジェクト: cardmaster/makeclub
	def can_createClub(self, *args):
		cq = Club.all()
		if (not self.user):
			return False
		cq.filter('owner =', self.user)
		if (cq.count() < conf.MaxClubsPerUser):
			return True
		elif ( users.is_current_user_admin() and self.user == users.get_current_user()):
			return True
		else:
			return False
コード例 #4
0
ファイル: main.py プロジェクト: skitazaki/jleague-calendar
 def get(self):
     include_club = False
     v = self.request.get('include')
     if v == 'club':
         include_club = True
     stadiums = []
     for s in Stadium.all().order('-location'):
         # Hand-made GeoJSON.
         p = {
             'type': 'Feature',
             'id': None,
             'properties': {
                 'abbr': s.abbr,
                 'name': s.display_name,
                 'wikipedia': s.wikipedia_url
             },
             'geometry': {
                 'type': 'Point',
                 'coordinates': [
                     s.location.lon, s.location.lat
                 ]
             }
         }
         if include_club:
             q = Club.all().filter('stadium =', s.abbr)
             clubs = []
             for c in q:
                 clubs.append({
                     'key': c.key().name(),
                     'category': c.category,
                     'url': c.url,
                     'name': c.display
                 })
             if len(clubs) > 0:
                 p['properties']['clubs'] = clubs
         stadiums.append(p)
     # See IANA official document.
     # http://www.iana.org/assignments/media-types/application/vnd.geo+json
     self.response.headers["Content-Type"] = "application/vnd.geo+json"
     json.dump({'type': 'FeatureCollection', 'features': stadiums},
               self.response.out)
コード例 #5
0
ファイル: admin.py プロジェクト: thenoviceoof/flyer-poke
    def get(self):
        timestamp = time.mktime(datetime.now().timetuple())-24*3600
        yesterday = datetime.fromtimestamp(timestamp)
        # count how many flyers are going out
        current_date = datetime.now(CurrentTimeZone())
        day = current_date.weekday() # starts 0=monday... 6=sunday
        if day < 5:
            job_query = Job.all()
            job_query.filter("active =", True)
            job_query.filter("state !=", DONE)
            flyer_count = job_query.count()
        else:
            flyer_count = 0
        # get new clubs
        club_query = Club.all()
        club_query.filter("created_at >", yesterday)
        new_clubs = club_query.fetch(20)
        # get new emails
        email_query = Email.all()
        email_query.filter("created_at >", yesterday)
        new_emails = email_query.fetch(100)
        # get new flyers
        flyer_query = Flyer.all()
        flyer_query.filter("created_at >", yesterday)
        new_flyers = flyer_query.fetch(50)
        # get new EmailToClub
        joint_query = EmailToClub.all()
        joint_query.filter("created_at >", yesterday)
        new_joints = joint_query.fetch(100)
        # and get the newly disabled links
        joint_query = EmailToClub.all()
        joint_query.filter("updated_at >", yesterday)
        joint_query.filter("enable =", False)
        dead_joints = joint_query.fetch(100)

        if (not(new_clubs) and not(new_emails) and not(new_flyers)
            and not(new_joints)):
            self.response.out.write("Nothing to email")
            return

        # email sending pre-computation
        fromaddr = "noreply@%s.appspotmail.com" % get_application_id()
        date = time.strftime("%Y/%m/%d")

        # send the emails
        msg = mail.EmailMessage(sender = "Flyer Guy <%s>" % fromaddr,
                                to = ADMIN_EMAIL)
        msg.subject = "[Flyer] Admin stats (%s)" % date
        msg.html    = template.render("templates/email_stats.html",
                                      {"flyer_count": flyer_count,
                                       "clubs": new_clubs,
                                       "emails": new_emails,
                                       "flyers": new_flyers,
                                       "joints": new_joints,
                                       "dead_joints": dead_joints})
        try:
            msg.send()
        except apiproxy_errors.OverQuotaError, (message,):
            # Log the error.
            logging.error("Could not send email")
            logging.error(message)