Example #1
0
 async def get(self, *, tid: objectid.ObjectId):
     tdoc = await contest.get(self.domain_id, document.TYPE_HOMEWORK, tid)
     if not self.own(tdoc, builtin.PERM_EDIT_HOMEWORK_SELF):
         self.check_perm(builtin.PERM_EDIT_HOMEWORK)
     begin_at = pytz.utc.localize(tdoc['begin_at']).astimezone(
         self.timezone)
     penalty_since = pytz.utc.localize(tdoc['penalty_since']).astimezone(
         self.timezone)
     end_at = pytz.utc.localize(tdoc['end_at']).astimezone(self.timezone)
     extension_days = round(
         (end_at - penalty_since).total_seconds() / 60 / 60 / 24, ndigits=2)
     page_title = self.translate('homework_edit')
     path_components = self.build_path(
         (self.translate('homework_main'),
          self.reverse_url('homework_main')),
         (tdoc['title'],
          self.reverse_url('homework_detail', tid=tdoc['doc_id'])),
         (page_title, None))
     self.render('homework_edit.html',
                 tdoc=tdoc,
                 date_begin_text=begin_at.strftime('%Y-%m-%d'),
                 time_begin_text=begin_at.strftime('%H:%M'),
                 date_penalty_text=penalty_since.strftime('%Y-%m-%d'),
                 time_penalty_text=penalty_since.strftime('%H:%M'),
                 extension_days=extension_days,
                 penalty_rules=_format_penalty_rules_yaml(
                     tdoc['penalty_rules']),
                 pids=contest._format_pids(tdoc['pids']),
                 page_title=page_title,
                 path_components=path_components)
Example #2
0
 async def get(self):
     dt = self.now.replace(tzinfo=pytz.utc).astimezone(self.timezone)
     ts = calendar.timegm(dt.utctimetuple())
     # find next quarter
     ts = ts - ts % (15 * 60) + 15 * 60
     dt = datetime.datetime.fromtimestamp(ts, self.timezone)
     self.render('contest_edit.html',
                 date_text=dt.strftime('%Y-%m-%d'),
                 time_text=dt.strftime('%H:%M'),
                 pids=contest._format_pids([1000, 1001]))
Example #3
0
 async def get(self):
   rules = list(map(lambda i: (i, constant.contest.RULE_TEXTS[i]),
                    constant.contest.CONTEST_RULES))
   dt = self.now.replace(tzinfo=pytz.utc).astimezone(self.timezone)
   ts = calendar.timegm(dt.utctimetuple())
   # find next quarter
   ts = ts - ts % (15 * 60) + 15 * 60
   dt = datetime.datetime.fromtimestamp(ts, self.timezone)
   self.render('contest_edit.html', rules=rules,
               date_text=dt.strftime('%Y-%m-%d'),
               time_text=dt.strftime('%H:%M'),
               pids=contest._format_pids([1000, 1001]))
Example #4
0
File: contest.py Project: vijos/vj4
 async def get(self):
   rules = list(map(lambda i: (i, constant.contest.RULE_TEXTS[i]),
                    constant.contest.CONTEST_RULES))
   dt = self.now.replace(tzinfo=pytz.utc).astimezone(self.timezone)
   ts = calendar.timegm(dt.utctimetuple())
   # find next quarter
   ts = ts - ts % (15 * 60) + 15 * 60
   dt = datetime.datetime.fromtimestamp(ts, self.timezone)
   self.render('contest_edit.html', rules=rules,
               date_text=dt.strftime('%Y-%m-%d'),
               time_text=dt.strftime('%H:%M'),
               pids=contest._format_pids([1000, 1001]))
Example #5
0
 async def get(self):
   begin_at = self.now.replace(tzinfo=pytz.utc).astimezone(self.timezone) + datetime.timedelta(days=1)
   penalty_since = begin_at + datetime.timedelta(days=7)
   page_title = self.translate('homework_create')
   path_components = self.build_path((page_title, None))
   self.render('homework_edit.html',
               date_begin_text=begin_at.strftime('%Y-%m-%d'),
               time_begin_text='00:00',
               date_penalty_text=penalty_since.strftime('%Y-%m-%d'),
               time_penalty_text='23:59',
               pids=contest._format_pids([1000, 1001]),
               extension_days='1',
               page_title=page_title, path_components=path_components)
Example #6
0
 async def get(self):
   begin_at = self.now.replace(tzinfo=pytz.utc).astimezone(self.timezone) + datetime.timedelta(days=1)
   penalty_since = begin_at + datetime.timedelta(days=7)
   page_title = self.translate('homework_create')
   path_components = self.build_path((page_title, None))
   self.render('homework_edit.html',
               date_begin_text=begin_at.strftime('%Y-%m-%d'),
               time_begin_text='00:00',
               date_penalty_text=penalty_since.strftime('%Y-%m-%d'),
               time_penalty_text='23:59',
               pids=contest._format_pids([1000, 1001]),
               extension_days='1',
               page_title=page_title, path_components=path_components)
Example #7
0
 async def get(self, *, tid: objectid.ObjectId):
   rules = list(map(lambda i: (i, constant.contest.RULE_TEXTS[i]),
                    constant.contest.CONTEST_RULES))
   tdoc = await contest.get(self.domain_id, document.TYPE_CONTEST, tid)
   if not self.own(tdoc, builtin.PERM_EDIT_CONTEST_SELF):
     self.check_perm(builtin.PERM_EDIT_CONTEST)
   dt = pytz.utc.localize(tdoc['begin_at']).astimezone(self.timezone)
   duration = (tdoc['end_at'] - tdoc['begin_at']).total_seconds() / 3600
   path_components = self.build_path(
       (self.translate('contest_main'), self.reverse_url('contest_main')),
       (tdoc['title'], self.reverse_url('contest_detail', tid=tdoc['doc_id'])),
       (self.translate('contest_edit'), None))
   self.render('contest_edit.html', rules=rules, tdoc=tdoc,
               date_text=dt.strftime('%Y-%m-%d'),
               time_text=dt.strftime('%H:%M'),
               duration=duration,
               pids=contest._format_pids(tdoc['pids']),
               path_components=path_components)
Example #8
0
File: contest.py Project: vijos/vj4
 async def get(self, *, tid: objectid.ObjectId):
   rules = list(map(lambda i: (i, constant.contest.RULE_TEXTS[i]),
                    constant.contest.CONTEST_RULES))
   tdoc = await contest.get(self.domain_id, document.TYPE_CONTEST, tid)
   if not self.own(tdoc, builtin.PERM_EDIT_CONTEST_SELF):
     self.check_perm(builtin.PERM_EDIT_CONTEST)
   dt = pytz.utc.localize(tdoc['begin_at']).astimezone(self.timezone)
   duration = (tdoc['end_at'] - tdoc['begin_at']).total_seconds() / 3600
   path_components = self.build_path(
       (self.translate('contest_main'), self.reverse_url('contest_main')),
       (tdoc['title'], self.reverse_url('contest_detail', tid=tdoc['doc_id'])),
       (self.translate('contest_edit'), None))
   self.render('contest_edit.html', rules=rules, tdoc=tdoc,
               date_text=dt.strftime('%Y-%m-%d'),
               time_text=dt.strftime('%H:%M'),
               duration=duration,
               pids=contest._format_pids(tdoc['pids']),
               path_components=path_components)
Example #9
0
 async def get(self, *, tid: objectid.ObjectId):
   tdoc = await contest.get(self.domain_id, document.TYPE_HOMEWORK, tid)
   if not self.own(tdoc, builtin.PERM_EDIT_HOMEWORK_SELF):
     self.check_perm(builtin.PERM_EDIT_HOMEWORK)
   begin_at = pytz.utc.localize(tdoc['begin_at']).astimezone(self.timezone)
   penalty_since = pytz.utc.localize(tdoc['penalty_since']).astimezone(self.timezone)
   end_at = pytz.utc.localize(tdoc['end_at']).astimezone(self.timezone)
   extension_days = round((end_at - penalty_since).total_seconds() / 60 / 60 / 24, ndigits=2)
   page_title = self.translate('homework_edit')
   path_components = self.build_path(
       (self.translate('homework_main'), self.reverse_url('homework_main')),
       (tdoc['title'], self.reverse_url('homework_detail', tid=tdoc['doc_id'])),
       (page_title, None))
   self.render('homework_edit.html', tdoc=tdoc,
               date_begin_text=begin_at.strftime('%Y-%m-%d'),
               time_begin_text=begin_at.strftime('%H:%M'),
               date_penalty_text=penalty_since.strftime('%Y-%m-%d'),
               time_penalty_text=penalty_since.strftime('%H:%M'),
               extension_days=extension_days,
               penalty_rules=_format_penalty_rules_yaml(tdoc['penalty_rules']),
               pids=contest._format_pids(tdoc['pids']),
               page_title=page_title, path_components=path_components)