def post(self, url): self.tf.send({'profile.racelog.adds': 1}, lambda x: x) error = self.get_error() year = datetime.date.today().year user = yield self.get_current_user_async() profile = yield models.get_user_by_url(self.redis, url) if user.email != profile.email: self.redirect_msg('/', {'error': 'You do not have permission to do add a run for this user.'}) return date = self.get_argument('date', '') date = dateutil.parser.parse(date, fuzzy=True) name = self.get_argument('name', '') distance = self.get_argument('distance', '') distance = float(distance) distance_units = self.get_argument('distance_units', '') time = self.get_argument('time', '') pacetime = self.get_argument('pacetime', 'time') notes = self.get_argument('notes', '') try: time = models.time_to_seconds(time) if time != '' else 0 except ValueError, e: msg = "The value you entered for time was not valid. Please enter your time in format HH:MM:SS or MM:SS or MM." self.redirect_msg('/u/%s' % user.url, {'error': msg}) return
def get(self, uri): self.tf.send({'profile.data.7daymileage': 1}, lambda x: x) user = yield models.get_user_by_url(self.redis, uri) date = self.get_argument('date', str(datetime.date.today())) try: date = dateutil.parser.parse(date) except ValueError, e: self.finish({'status': False}) return
def get(self, url): self.tf.send({'profile.racelog.views': 1}, lambda x: x) error = self.get_error() year = datetime.date.today().year user = yield self.get_current_user_async() profile = yield models.get_user_by_url(self.redis, url) races = models.Race.objects(user=profile).order_by('-date') self.render('races.html', page_title='Racelog', user=user, today=datetime.date.today().strftime("%x"), error=error, this_year=year, profile=profile, races=races)
def get(self, userurl, run): user = yield self.get_current_user_async() profile = yield models.get_user_by_url(self.redis, userurl) run = models.Run.objects(id=run).first() if run is None: self.send_error(404) return year = datetime.date.today().year yield gen.Task(self.tf.send, {'profile.runs.views': 1}) self.render('run.html', page_title='{}\'s {} mile run'.format(profile.display_name, run.distance), user=user, profile=profile, run=run, error=None, this_year=year)
def get(self, userurl, raceid): user = yield self.get_current_user_async() profile = yield models.get_user_by_url(self.redis, userurl) race = models.Race.objects(id=raceid).first() if race == None: # 404 self.send_error(404) return year = datetime.date.today().year yield gen.Task(self.tf.send, {'profile.races.views': 1}) title = '{} raced {} - {} {}'.format(profile.display_name, race.name, race.distance, race.distance_units) self.render('race.html', page_title=title, user=user, profile=profile, race=race, error=None, this_year=year)
def get(self, userurl): user = yield self.get_current_user_async() profile = yield models.get_user_by_url(self.redis, userurl) keywords = self.get_argument('keywords', None) runs = yield self.get_runs(profile, keywords) year = datetime.date.today().year title = '{}\'s training log'.format(profile.display_name) def run_uri(run): return '/u/{}/run/{}'.format(profile.url, str(run.id)) yield gen.Task(self.tf.send, {'profile.allruns.views': 1}) def render(): self.render( 'allruns.html', page_title=title, user=user, profile=profile, runs=runs, error=None, this_year=year, run_uri=run_uri, keywords=keywords) yield self.execute_thread(render)
def get(self, url): self.tf.send({'profile.dashboard.views': 1}, lambda x: x) error = self.get_error() user = yield self.get_current_user_async() profile = user # if we're not looking at our own # we show another profile if it's public if not user or user.url != url: profile = yield models.get_user_by_url(self.redis, url) if not profile: self.send_error(404) return recent_runs = yield self.execute_thread( models.Run.get_recent_runs, profile, 10) week = yield self.execute_thread( models.Week.this_week, profile) year = datetime.date.today().year self.render('dashboard.html', page_title='Dashboard', user=user, recent_runs=recent_runs, today=datetime.date.today().strftime("%x"), error=error, week=week, this_year=year, profile=profile)
def get(self, uri): self.tf.send({'profile.data.profile': 1}, lambda x: x) user = yield models.get_user_by_url(self.redis, uri) self.finish(user.public_dict())
def get(self, uri): self.tf.send({'profile.data.recentruns': 1}, lambda x: x) user = yield models.get_user_by_url(self.redis, uri) data = models.Run.get_recent_runs(user, 10) data = [x.public_dict() for x in data] self.finish({'data': data})