Exemple #1
0
 def get(self):
     sessionid = extractkeyfromrequest(self.request, 's')
     if sessionid:
         sessionid = sessionid.strip()
     user = None
     isnewuser = False
     isfuture = False
     isrecservicesclaz = False
     if sessionid:
         cacheservice = MemcacheService()
         user = cacheservice.getsessionuser(sessionid)
         isnewuser = cacheservice.getfromsession(sessionid, "newuser")
     # uid, insession = attemptlogin(self.request)
     # coursesservice = CoursesService()
     # courses = coursesservice.listupcomingcourses()
     template_values = {
         'sessionid': sessionid,
         'user': user,
         'isnewuser': isnewuser,
         'isfuture': isfuture,
         'isrecservicesclaz': isrecservicesclaz
     }
     if sessionid:
         cacheservice.clearfromsession(sessionid, "newuser")
     template = JINJA_ENVIRONMENT.get_template('subscribe.html')
     self.response.write(template.render(template_values))
Exemple #2
0
 def get(self):
     sessionid = extractkeyfromrequest(self.request, 's')
     if sessionid:
         sessionid = sessionid.strip()
     user = None
     if sessionid:
         cacheservice = MemcacheService()
         user = cacheservice.getsessionuser(sessionid)
     # uid, insession = attemptlogin(self.request)
     # coursesservice = CoursesService()
     # courses = coursesservice.listupcomingcourses()
     template_values = {
         'sessionid': sessionid,
         'user': user,
         'newuser': False,
     }
     # uid, insession = attemptlogin(self.request)
     # coursesservice = CoursesService()
     # courses = coursesservice.listupcomingcourses()
     # header_template_values = buildheadertemplatevalues(insession, uid)
     # template_values.update(header_template_values)
     # course_template_values = buildallcoursestemplatevalues(insession, courses)
     # template_values.update(course_template_values)
     template = JINJA_ENVIRONMENT.get_template('index-ace.html')
     self.response.write(template.render(template_values))
Exemple #3
0
 def get(self, *args, **kwargs):
     if not super(NewDefaultPair, self).get(*args, **kwargs):
         return
     group_id = kwargs.get('group_id')
     default_day = self.request.get('weekday')
     if not default_day.isdigit():
         default_day = 0
     else:
         default_day = int(default_day) % 14
     pair = DefaultPair(classname='classname',
                        week_day=default_day,
                        start_time=datetime.time(9, 10),
                        duration=90,
                        group_id=group_id,
                        pair_type='')
     return_url = self.request.get('return_url')
     if return_url is None:
         return_url = '/' + group_id + '/default_pairs'
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'edit_default_pair.html')
     subjects_qry = Subject.query(Subject.group_id == group_id).order(Subject.classname)
     self.render_data['subjects'] = subjects_qry
     self.render_data['pair'] = pair
     self.render_data['return_url'] = return_url
     self.response.write(template.render(self.render_data))
Exemple #4
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     emailid = extractkeyfromrequest(self.request, 'e')
     if emailid is None:
         emailid = ''
     zipcode = extractkeyfromrequest(self.request, 'z')
     if zipcode is None:
         zipcode = ''
     returnvalue = extractkeyfromrequest(self.request, 'r')
     if returnvalue is None:
         returnvalue = 0
     returnvalue = int(returnvalue)
     template_values = {
         'emailid': emailid,
         'zipcode': zipcode,
         'returnvalue': returnvalue,
     }
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     channelpartnersservice = ChannelPartnersService()
     channelpartners = channelpartnersservice.getchannelpartners()
     channelpartner_template_values = buildchannelpartnertemplatevalues(
         insession, channelpartners)
     template_values.update(channelpartner_template_values)
     template = JINJA_ENVIRONMENT.get_template('signup.html')
     self.response.write(template.render(template_values))
Exemple #5
0
 def get(self, *args, **kwargs):
     if not super(NewPair, self).get(*args, **kwargs):
         return
     default_day = self.request.get('date')
     if default_day is None or default_day == "":
         default_day = timezone.today()
     else:
         default_day = timezone.datefromstr(default_day)
     pair = ScheduledPair(classname='',
                          date=default_day,
                          start_time=datetime.time(9, 10),
                          duration=90,
                          replace=True,
                          task='',
                          pair_type='')
     return_url = self.request.get('return_url')
     if return_url is None:
         return_url = '/' + group_id + '/pairs'
     template = JINJA_ENVIRONMENT.get_template('templates/edit_pair.html')
     subjects_qry = Subject.query(
         Subject.group_id == self.render_data['group_id']).order(
             Subject.classname)
     self.render_data['subjects'] = subjects_qry
     self.render_data['pair'] = pair
     self.render_data['return_url'] = return_url
     self.response.write(template.render(self.render_data))
Exemple #6
0
 def get(self):
     sessionid = extractkeyfromrequest(self.request, 's')
     if sessionid:
         sessionid = sessionid.strip()
     user = None
     cacheservice = MemcacheService()
     if sessionid:
         user = cacheservice.getsessionuser(sessionid)
     template_values = {'sessionid': sessionid, 'user': user}
     if sessionid:
         for i in range(1, 101):
             template_values['quiz' + str(i) +
                             'submitted'] = cacheservice.getfromsession(
                                 sessionid, 'quiz' + str(i) + 'submitted')
             template_values['quiz' + str(i) +
                             'results'] = cacheservice.getfromsession(
                                 sessionid, 'quiz' + str(i) + 'results')
             template_values['quiz' + str(i) +
                             'len'] = cacheservice.getfromsession(
                                 sessionid, 'quiz' + str(i) + 'len')
         for i in range(1, 101):
             cacheservice.clearfromsession(sessionid,
                                           'quiz' + str(i) + 'submitted')
             cacheservice.clearfromsession(sessionid,
                                           'quiz' + str(i) + 'results')
             cacheservice.clearfromsession(sessionid,
                                           'quiz' + str(i) + 'len')
     template = JINJA_ENVIRONMENT.get_template('programmingusingjava.html')
     self.response.write(template.render(template_values))
Exemple #7
0
 def get(self, *args, **kwargs):
     if not super(NewDefaultPair, self).get(*args, **kwargs):
         return
     group_id = kwargs.get('group_id')
     default_day = self.request.get('weekday')
     if not default_day.isdigit():
         default_day = 0
     else:
         default_day = int(default_day) % 14
     pair = DefaultPair(classname='classname',
                        week_day=default_day,
                        start_time=datetime.time(9, 10),
                        duration=90,
                        group_id=group_id,
                        pair_type='')
     return_url = self.request.get('return_url')
     if return_url is None:
         return_url = '/' + group_id + '/default_pairs'
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'edit_default_pair.html')
     subjects_qry = Subject.query(Subject.group_id == group_id).order(
         Subject.classname)
     self.render_data['subjects'] = subjects_qry
     self.render_data['pair'] = pair
     self.render_data['return_url'] = return_url
     self.response.write(template.render(self.render_data))
Exemple #8
0
 def get(self, *args, **kwargs):
     if not super(NewSubject, self).get(*args, **kwargs):
         return
     subject = Subject(classname='', teacher='')
     template = JINJA_ENVIRONMENT.get_template(
         'templates/edit_subject.html')
     self.render_data['subject'] = subject
     self.response.write(template.render(self.render_data))
    def get(self):
        user = users.get_current_user()

        if user:
            template = JINJA_ENVIRONMENT.get_template('index.html')
            self.response.write(template.render({'user': user}))
        else:
            self.redirect(users.create_login_url(self.request.uri))
Exemple #10
0
 def get(self, *args, **kwargs):
     if not super(NewSubject, self).get(*args, **kwargs):
         return
     subject = Subject(classname='',
                       teacher='')
     template = JINJA_ENVIRONMENT.get_template('templates/edit_subject.html')
     self.render_data['subject'] = subject
     self.response.write(template.render(self.render_data))
Exemple #11
0
 def get(self, *args, **kwargs):
     super(ShowSubject, self).get(*args, **kwargs)
     url_key = self.request.get('key')
     key = ndb.Key(urlsafe=url_key)
     subject = key.get()
     template = JINJA_ENVIRONMENT.get_template('templates/show_subject.html')
     self.render_data['subject'] = subject
     self.response.write(template.render(self.render_data))
Exemple #12
0
 def get(self, *args, **kwargs):
     super(ShowSubject, self).get(*args, **kwargs)
     url_key = self.request.get('key')
     key = ndb.Key(urlsafe=url_key)
     subject = key.get()
     template = JINJA_ENVIRONMENT.get_template(
         'templates/show_subject.html')
     self.render_data['subject'] = subject
     self.response.write(template.render(self.render_data))
Exemple #13
0
 def get(self, *args, **kwargs):
     if not super(CopyFromDefault, self).get(*args, **kwargs):
         return
     date_begin = timezone.today()
     date_end = timezone.today() + datetime.timedelta(days=13)
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'copy_from_default.html')
     self.render_data['date_begin'] = str(date_begin)
     self.render_data['date_end'] = str(date_end)
     self.response.write(template.render(self.render_data))
Exemple #14
0
 def get(self, *args, **kwargs):
     if not super(EditSubject, self).get(*args, **kwargs):
         return
     url_key = self.request.get('key')
     key = ndb.Key(urlsafe=url_key)
     subject = key.get()
     template = JINJA_ENVIRONMENT.get_template('templates/edit_subject.html')
     self.render_data['subject'] = subject
     self.render_data['key_urlsafe'] = url_key
     self.response.write(template.render(self.render_data))
Exemple #15
0
 def get(self, *args, **kwargs):
     if not super(CopyFromDefault, self).get(*args, **kwargs):
         return
     date_begin = timezone.today()
     date_end = timezone.today() + datetime.timedelta(days=13)
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'copy_from_default.html')
     self.render_data['date_begin'] = str(date_begin)
     self.render_data['date_end'] = str(date_end)
     self.response.write(template.render(self.render_data))
Exemple #16
0
def render_template(temp_path,
                    title,
                    requested_chat=None,
                    room_spec_msgs=False):
    template_values = defaultParams(title, requested_chat)
    if room_spec_msgs:
        template_values['msg_list'] = getMessages(chat=requested_chat)
    else:
        template_values['msg_list'] = getMessages()
    template = JINJA_ENVIRONMENT.get_template(temp_path)
    return template.render(template_values)
Exemple #17
0
 def get(self, *args, **kwargs):
     if not super(EditSubject, self).get(*args, **kwargs):
         return
     url_key = self.request.get('key')
     key = ndb.Key(urlsafe=url_key)
     subject = key.get()
     template = JINJA_ENVIRONMENT.get_template(
         'templates/edit_subject.html')
     self.render_data['subject'] = subject
     self.render_data['key_urlsafe'] = url_key
     self.response.write(template.render(self.render_data))
Exemple #18
0
 def get(self):
     # uid, insession = attemptlogin(self.request)
     # coursesservice = CoursesService()
     # courses = coursesservice.listupcomingcourses()
     template_values = {}
     # header_template_values = buildheadertemplatevalues(insession, uid)
     # template_values.update(header_template_values)
     # course_template_values = buildallcoursestemplatevalues(insession, courses)
     # template_values.update(course_template_values)
     template = JINJA_ENVIRONMENT.get_template('scholarship.html')
     self.response.write(template.render(template_values))
Exemple #19
0
 def get(self):
     basedir = os.path.dirname(__file__)
     staticdir = os.path.join(basedir, 'static')
     staticfiles = os.listdir(staticdir)
     staticfiles = [
         staticfile for staticfile in staticfiles
         if not staticfile.startswith('.')
     ]
     template_values = {}
     template_values['staticfiles'] = staticfiles
     template = JINJA_ENVIRONMENT.get_template('classroom.html')
     self.response.write(template.render(template_values))
Exemple #20
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     coursesservice = CoursesService()
     courses = coursesservice.listcourses()
     template_values = {}
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     course_template_values = buildallcoursestemplatevalues(
         insession, courses)
     template_values.update(course_template_values)
     # logging.info('template_values='+str(template_values))
     template = JINJA_ENVIRONMENT.get_template('allcourses.html')
     self.response.write(template.render(template_values))
Exemple #21
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     returnvalue = extractkeyfromrequest(self.request, 'r')
     hasreturnvalue = True
     if returnvalue is None:
         hasreturnvalue = False
     emailid = extractkeyfromrequest(self.request, 'e')
     template_values = {
         'emailid': emailid,
         'hasreturnvalue': hasreturnvalue,
     }
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     template = JINJA_ENVIRONMENT.get_template('signupstatus.html')
     self.response.write(template.render(template_values))
Exemple #22
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     coursesservice = CoursesService()
     userservice = UserService()
     emailid = userservice.getemailidforsession(uid)
     usercourses = coursesservice.listusercourses(emailid)
     template_values = {}
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     course_template_values = buildmycoursestemplatevalues(
         insession, uid, usercourses)
     template_values.update(course_template_values)
     template = JINJA_ENVIRONMENT.get_template('mycourses.html?s=' +
                                               str(sessionid))
     self.response.write(template.render(template_values))
Exemple #23
0
 def get(self, *args, **kwargs):
     group_id = kwargs.get('group_id')
     if not super(ShowPairs, self).get(*args, **kwargs):
         return
     pairs_qry = ScheduledPair.query(
         ScheduledPair.group_id == group_id).order(ScheduledPair.date,
                                                   ScheduledPair.start_time)
     template = JINJA_ENVIRONMENT.get_template('templates/pairs.html')
     self.render_data['pairs'] = []
     for pair in pairs_qry:
         pair.edit_link = '/' + group_id + '/edit_pair?key=' +\
                          pair.key.urlsafe()
         pair.delete_link = '/' + group_id + '/delete_pair?key=' +\
             pair.key.urlsafe() + '&return_url=/' + group_id + '/pairs'
         self.render_data['pairs'].append(pair)
     self.response.write(template.render(self.render_data))
Exemple #24
0
 def get(self, *args, **kwargs):
     if not super(EditSettings, self).get(*args, **kwargs):
         return
     settings_qry = ScheduleSettings.query().fetch(1)
     if len(settings_qry) == 0:
         settings = ScheduleSettings(schedule_period=7,
                                     first_week_begin=DEFAULT_MONDAY,
                                     group_id=kwargs.get('group_id'))
         settings.put()
     else:
         settings = settings_qry[0]
     self.render_data['schedule_period'] = settings.schedule_period
     self.render_data['first_week_begin'] = settings.first_week_begin
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'schedule_settings.html')
     self.response.write(template.render(self.render_data))
Exemple #25
0
 def get(self, *args, **kwargs):
     if not super(EditSettings, self).get(*args, **kwargs):
         return
     settings_qry = ScheduleSettings.query().fetch(1)
     if len(settings_qry) == 0:
         settings = ScheduleSettings(schedule_period=7,
                                     first_week_begin=DEFAULT_MONDAY,
                                     group_id=kwargs.get('group_id'))
         settings.put()
     else:
         settings = settings_qry[0]
     self.render_data['schedule_period'] = settings.schedule_period
     self.render_data['first_week_begin'] = settings.first_week_begin
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'schedule_settings.html')
     self.response.write(template.render(self.render_data))
Exemple #26
0
 def get(self, *args, **kwargs):
     group_id = kwargs.get('group_id')
     if not super(ShowSubjects, self).get(*args, **kwargs):
         return
     subjects_qry = Subject.query(Subject.group_id == group_id)
     template = JINJA_ENVIRONMENT.get_template('templates/subjects.html')
     self.render_data['subjects'] = []
     for subject in subjects_qry:
         subject.edit_link = '/' + group_id + '/edit_subject?key=' +\
                          subject.key.urlsafe()
         subject.delete_link = '/' + group_id + '/delete_subject?key=' +\
             subject.key.urlsafe() + '&return_url=/' + group_id + '/subjects'
         subject.link = '/' + group_id + '/subject?key=' +\
             subject.key.urlsafe()
         self.render_data['subjects'].append(subject)
     self.response.write(template.render(self.render_data))
Exemple #27
0
 def get(self, *args, **kwargs):
     if not super(EditPair, self).get(*args, **kwargs):
         return
     url_key = self.request.get('key')
     key = ndb.Key(urlsafe=url_key)
     pair = key.get()
     return_url = self.request.get('return_url')
     if return_url is None:
         return_url = '/' + group_id + '/pairs'
     template = JINJA_ENVIRONMENT.get_template('templates/edit_pair.html')
     subjects_qry = Subject.query(Subject.group_id == self.render_data['group_id']).order(Subject.classname)
     self.render_data['subjects'] = subjects_qry
     self.render_data['pair'] = pair
     self.render_data['key_urlsafe'] = url_key
     self.render_data['return_url'] = return_url
     self.response.write(template.render(self.render_data))
Exemple #28
0
 def get(self):
     sessionid = extractkeyfromrequest(self.request, 's')
     if sessionid:
         sessionid = sessionid.strip()
     user = None
     cacheservice = MemcacheService()
     if sessionid:
         user = cacheservice.getsessionuser(sessionid)
     template_values = {'sessionid': sessionid, 'user': user}
     for i in range(1, 10):
         template_values['quiz' + str(i) +
                         'submitted'] = cacheservice.getfromsession(
                             sessionid, 'quiz' + str(i) + 'submitted')
         template_values['quiz' + str(i) +
                         'results'] = cacheservice.getfromsession(
                             sessionid, 'quiz' + str(i) + 'results')
         template_values['quiz' + str(i) +
                         'len'] = cacheservice.getfromsession(
                             sessionid, 'quiz' + str(i) + 'len')
     for i in range(1, 10):
         template_values['hw' + str(i) +
                         'submitted'] = cacheservice.getfromsession(
                             sessionid, 'hw' + str(i) + 'submitted')
         template_values['hw' + str(i) +
                         'results'] = cacheservice.getfromsession(
                             sessionid, 'hw' + str(i) + 'results')
         template_values['hw' + str(i) +
                         'len'] = cacheservice.getfromsession(
                             sessionid, 'hw' + str(i) + 'len')
     logging.info("APComputerSciencePage template_values=" +
                  str(template_values))
     if sessionid:
         for i in range(1, 10):
             cacheservice.clearfromsession(sessionid,
                                           'quiz' + str(i) + 'submitted')
             cacheservice.clearfromsession(sessionid,
                                           'quiz' + str(i) + 'results')
             cacheservice.clearfromsession(sessionid,
                                           'quiz' + str(i) + 'len')
         for i in range(1, 10):
             cacheservice.clearfromsession(sessionid,
                                           'hw' + str(i) + 'submitted')
             cacheservice.clearfromsession(sessionid,
                                           'hw' + str(i) + 'results')
             cacheservice.clearfromsession(sessionid, 'hw' + str(i) + 'len')
     template = JINJA_ENVIRONMENT.get_template('apcomputerscience.html')
     self.response.write(template.render(template_values))
Exemple #29
0
 def get(self, *args, **kwargs):
     group_id = kwargs.get('group_id')
     if not super(ShowPairs, self).get(*args, **kwargs):
         return
     pairs_qry = ScheduledPair.query(ScheduledPair.group_id ==
                                     group_id).order(ScheduledPair.date,
                                                     ScheduledPair.
                                                     start_time)
     template = JINJA_ENVIRONMENT.get_template('templates/pairs.html')
     self.render_data['pairs'] = []
     for pair in pairs_qry:
         pair.edit_link = '/' + group_id + '/edit_pair?key=' +\
                          pair.key.urlsafe()
         pair.delete_link = '/' + group_id + '/delete_pair?key=' +\
             pair.key.urlsafe() + '&return_url=/' + group_id + '/pairs'
         self.render_data['pairs'].append(pair)
     self.response.write(template.render(self.render_data))
Exemple #30
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     staffservice = StaffService()
     staff = staffservice.getstaff()
     channelpartnersservice = ChannelPartnersService()
     channelpartners = channelpartnersservice.getchannelpartners()
     template_values = {}
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     staff_template_values = buildstafftemplatevalues(insession, staff)
     template_values.update(staff_template_values)
     channelpartner_template_values = buildchannelpartnertemplatevalues(
         insession, channelpartners)
     template_values.update(channelpartner_template_values)
     # logging.error('template_values='+str(template_values))
     template = JINJA_ENVIRONMENT.get_template('about.html')
     self.response.write(template.render(template_values))
Exemple #31
0
 def get(self, *args, **kwargs):
     group_id = kwargs.get('group_id')
     if not super(ShowSubjects, self).get(*args, **kwargs):
         return
     subjects_qry = Subject.query(Subject.group_id ==
                                  group_id)
     template = JINJA_ENVIRONMENT.get_template('templates/subjects.html')
     self.render_data['subjects'] = []
     for subject in subjects_qry:
         subject.edit_link = '/' + group_id + '/edit_subject?key=' +\
                          subject.key.urlsafe()
         subject.delete_link = '/' + group_id + '/delete_subject?key=' +\
             subject.key.urlsafe() + '&return_url=/' + group_id + '/subjects'
         subject.link = '/' + group_id + '/subject?key=' +\
             subject.key.urlsafe()
         self.render_data['subjects'].append(subject)
     self.response.write(template.render(self.render_data))
Exemple #32
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     emailid = extractkeyfromrequest(self.request, 'e')
     if emailid is None:
         emailid = ''
     returnvalue = extractkeyfromrequest(self.request, 'r')
     if returnvalue is None:
         returnvalue = 0
     else:
         returnvalue = int(returnvalue)
     template_values = {
         'emailid': emailid,
         'returnvalue': returnvalue,
     }
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     template = JINJA_ENVIRONMENT.get_template('forgot.html')
     self.response.write(template.render(template_values))
Exemple #33
0
 def get(self, *args, **kwargs):
     if not super(EditPair, self).get(*args, **kwargs):
         return
     url_key = self.request.get('key')
     key = ndb.Key(urlsafe=url_key)
     pair = key.get()
     return_url = self.request.get('return_url')
     if return_url is None:
         return_url = '/' + group_id + '/pairs'
     template = JINJA_ENVIRONMENT.get_template('templates/edit_pair.html')
     subjects_qry = Subject.query(
         Subject.group_id == self.render_data['group_id']).order(
             Subject.classname)
     self.render_data['subjects'] = subjects_qry
     self.render_data['pair'] = pair
     self.render_data['key_urlsafe'] = url_key
     self.render_data['return_url'] = return_url
     self.response.write(template.render(self.render_data))
Exemple #34
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     emailid = extractkeyfromrequest(self.request, 'e')
     iserror = extractkeyfromrequest(self.request, 'x') != None
     errormsg = ''
     if iserror:
         errormsg = 'Unable to signin'
     if emailid is None:
         emailid = ''
     template_values = {
         'errormsg': errormsg,
         'emailid': emailid,
         'forgoturl': '/forgot?e=' + str(emailid),
         'forgoturllinktext': 'Forgot Student ID?'
     }
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     template = JINJA_ENVIRONMENT.get_template('signin.html')
     self.response.write(template.render(template_values))
Exemple #35
0
 def get(self, *args, **kwargs):
     #TODO : add normal editor
     template = JINJA_ENVIRONMENT.get_template('templates/global_word_editor.html')
     curr_json = GlobalDictionaryJson.get_by_key_name('json')
     render_data = {'words':[]}
     num = 0
     word_cnt = 0
     id = int(kwargs.get('id'))
     if curr_json is not None:
         for i in json.loads(curr_json.json):
             word_cnt += 1
             if i['tags'].find('-deleted') != -1 or word_cnt <= id * 200 or word_cnt > (id + 1) * 200:
                 continue
             word = GlobalDictionaryWord(cnt=num, word=i['word'], E=i['E'], D=i['D'], tags=i['tags'])
             num += 1
             render_data['words'].append(word)
     render_data['quantity'] = num
     render_data['all_num'] = word_cnt
     self.response.write(template.render(render_data))
Exemple #36
0
    def get(self):
        self.response.headers["Content-Type"] = "text/html;charset=utf-8"

        delta = self.request.get("delta", default_value=None)
        req_chat = self.request.get("chat", default_value=None)
        stampf = self.request.get("format", default_value="%d-%m-%Y %H:%M")

        if delta:
            if not representsInt(delta):
                delta = None
            else:
                delta = int(delta)

        messages = getMessages(req_chat, delta)
        """logging.info( u"Chätti = " + str( req_chat ) )
        logging.info( "Viestit = " + str( messages ))
        logging.info( "Ajan leimausformaatti = " + str( stampf ) )
        #"""
        template_values = {'msg_list': messages, 'timestmpf': stampf}

        template = JINJA_ENVIRONMENT.get_template('./messages.json')
        page = template.render(template_values)  #"""
        self.response.out.write(page)
Exemple #37
0
 def get(self):
     uid, insession = attemptlogin(self.request)
     courseid = extractkeyfromrequest(self.request, 'c')
     coursecontentid = extractkeyfromrequest(self.request, 'cc')
     coursesservice = CoursesService()
     course = coursesservice.getcourse(courseid)
     coursecontents = coursesservice.getcoursecontents(courseid)
     coursehandouts = coursesservice.getcoursehandouts(courseid)
     coursehomeworks = coursesservice.getcoursehomeworks(courseid)
     coursevideos = coursesservice.getcoursevideos(courseid)
     coursestarterpacks = coursesservice.getcoursestarterpacks(courseid)
     coursequizzes = coursesservice.getcoursequizzes(courseid)
     template_values = {}
     header_template_values = buildheadertemplatevalues(insession, uid)
     template_values.update(header_template_values)
     coursecontent_template_values = buildcoursecontenttemplatevalues(
         insession, courseid, coursecontentid, course, coursecontents,
         coursehandouts, coursehomeworks, coursevideos, coursestarterpacks,
         coursequizzes)
     template_values.update(coursecontent_template_values)
     logging.info('template_values=' + str(template_values))
     template = JINJA_ENVIRONMENT.get_template('coursecontent.html')
     self.response.write(template.render(template_values))
Exemple #38
0
 def get(self):
     sessionid = extractkeyfromrequest(self.request, 's')
     if sessionid:
         sessionid = sessionid.strip()
     user = None
     isnewuser = False
     isfuture = False
     isrecservicesclaz = False
     if sessionid:
         cacheservice = MemcacheService()
         user = cacheservice.getsessionuser(sessionid)
         isnewuser = cacheservice.getfromsession(sessionid, "newuser")
         claz = cacheservice.getfromsession(sessionid, "claz")
         isfuture = claz == 'Future Sessions'
         isrecservicesclaz = claz == 'Sep 2015 - Nov 2015' or claz == 'Sep 2015 - Nov 2015 (AP)'
     # uid, insession = attemptlogin(self.request)
     # coursesservice = CoursesService()
     # courses = coursesservice.listupcomingcourses()
     template_values = {
         'sessionid': sessionid,
         'user': user,
         'isnewuser': isnewuser,
         'isfuture': isfuture,
         'isrecservicesclaz': isrecservicesclaz
     }
     if sessionid:
         cacheservice.clearfromsession(sessionid, "newuser")
     # uid, insession = attemptlogin(self.request)
     # coursesservice = CoursesService()
     # courses = coursesservice.listupcomingcourses()
     # header_template_values = buildheadertemplatevalues(insession, uid)
     # template_values.update(header_template_values)
     # course_template_values = buildallcoursestemplatevalues(insession, courses)
     # template_values.update(course_template_values)
     template = JINJA_ENVIRONMENT.get_template('register.html')
     self.response.write(template.render(template_values))
Exemple #39
0
 def get(self, *args, **kwargs):
     if not super(NewPair, self).get(*args, **kwargs):
         return
     default_day = self.request.get('date')
     if default_day is None or default_day == "":
         default_day = timezone.today()
     else:
         default_day = timezone.datefromstr(default_day)
     pair = ScheduledPair(classname='',
                          date=default_day,
                          start_time=datetime.time(9, 10),
                          duration=90,
                          replace=True,
                          task='',
                          pair_type='')
     return_url = self.request.get('return_url')
     if return_url is None:
         return_url = '/' + group_id + '/pairs'
     template = JINJA_ENVIRONMENT.get_template('templates/edit_pair.html')
     subjects_qry = Subject.query(Subject.group_id == self.render_data['group_id']).order(Subject.classname)
     self.render_data['subjects'] = subjects_qry
     self.render_data['pair'] = pair
     self.render_data['return_url'] = return_url
     self.response.write(template.render(self.render_data))
Exemple #40
0
 def get(self, *args, **kwargs):
     super(ShowDefaultSchedule, self).get(*args, **kwargs)
     group_id = kwargs.get('group_id')
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'default_schedule.html')
     settings_qry = ScheduleSettings.query(DefaultPair.group_id ==
                                           group_id).fetch(1)
     if len(settings_qry) == 0:
         settings = ScheduleSettings(schedule_period=7,
                                     first_week_begin=DEFAULT_MONDAY,
                                     group_id=group_id)
         settings.put()
     else:
         settings = settings_qry[0]
     self.render_data['double_week'] = settings.schedule_period == 14
     self.render_data['odd_days'] = [None] * 6
     min_start_time = timezone.timefromstr("23:59")
     max_end_time = timezone.timefromstr("00:00")
     for day in xrange(6):
         pairs_qry = DefaultPair.query(DefaultPair.week_day == day,
                                       DefaultPair.group_id == group_id).\
             order(DefaultPair.start_time)
         render_day = {'week_day': day, 'pairs': [],
                       'pair_add_link': '/' + group_id +
                       '/new_default_pair?weekday=' + str(day) +
                       '&return_url=/' + group_id + '/schedule'}
         for pair in pairs_qry:
             pair.edit_link = '/' + group_id + '/edit_default_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             pair.delete_link = '/' + group_id + '/delete_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             render_day['pairs'].append(pair)
             min_start_time = min(min_start_time, pair.start_time)
             max_end_time = max(max_end_time,
                                timezone.addtime(pair.start_time, timezone.timedelta(minutes=pair.duration)))
         self.render_data['odd_days'][day] = render_day
     coef = 1.2
     for day in self.render_data['odd_days']:
         for pair in day['pairs']:
             pair.from_up = 40 + int(timezone.gettimediff(pair.start_time, min_start_time).seconds / 60 / coef)
             pair.height = int(pair.duration / coef)
         day['height'] = 40 + int(timezone.gettimediff(max_end_time, min_start_time).seconds / 60 / coef) + 40
     self.render_data['even_days'] = [None] * 6
     min_start_time = timezone.timefromstr("23:59")
     max_end_time = timezone.timefromstr("00:00")
     for day in xrange(7, 13):
         pairs_qry = DefaultPair.query(DefaultPair.week_day == day,
                                       DefaultPair.group_id == group_id).\
             order(DefaultPair.start_time)
         render_day = {'week_day': day, 'pairs': [],
                       'pair_add_link': '/' + group_id +
                       '/new_default_pair?weekday=' + str(day) +
                       '&return_url=/' + group_id + '/schedule'}
         for pair in pairs_qry:
             pair.edit_link = '/' + group_id + '/edit_default_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             pair.delete_link = '/' + group_id + '/delete_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             min_start_time = min(min_start_time, pair.start_time)
             max_end_time = max(max_end_time,
                                timezone.addtime(pair.start_time, timezone.timedelta(minutes=pair.duration)))
             render_day['pairs'].append(pair)
         self.render_data['even_days'][day - 7] = render_day
     for day in self.render_data['even_days']:
         for pair in day['pairs']:
             pair.from_up = 40 + int(timezone.gettimediff(pair.start_time, min_start_time).seconds / 60 / coef)
             pair.height = int(pair.duration / coef)
         day['height'] = 40 + int(timezone.gettimediff(max_end_time, min_start_time).seconds / 60 / coef) + 40
     self.response.write(template.render(self.render_data))
Exemple #41
0
 def get(self, *args, **kwargs):
     super(ShowDefaultSchedule, self).get(*args, **kwargs)
     group_id = kwargs.get('group_id')
     template = JINJA_ENVIRONMENT.get_template('templates/'
                                               'default_schedule.html')
     settings_qry = ScheduleSettings.query(
         DefaultPair.group_id == group_id).fetch(1)
     if len(settings_qry) == 0:
         settings = ScheduleSettings(schedule_period=7,
                                     first_week_begin=DEFAULT_MONDAY,
                                     group_id=group_id)
         settings.put()
     else:
         settings = settings_qry[0]
     self.render_data['double_week'] = settings.schedule_period == 14
     self.render_data['odd_days'] = [None] * 6
     min_start_time = timezone.timefromstr("23:59")
     max_end_time = timezone.timefromstr("00:00")
     for day in xrange(6):
         pairs_qry = DefaultPair.query(DefaultPair.week_day == day,
                                       DefaultPair.group_id == group_id).\
             order(DefaultPair.start_time)
         render_day = {
             'week_day':
             day,
             'pairs': [],
             'pair_add_link':
             '/' + group_id + '/new_default_pair?weekday=' + str(day) +
             '&return_url=/' + group_id + '/schedule'
         }
         for pair in pairs_qry:
             pair.edit_link = '/' + group_id + '/edit_default_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             pair.delete_link = '/' + group_id + '/delete_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             render_day['pairs'].append(pair)
             min_start_time = min(min_start_time, pair.start_time)
             max_end_time = max(
                 max_end_time,
                 timezone.addtime(
                     pair.start_time,
                     timezone.timedelta(minutes=pair.duration)))
         self.render_data['odd_days'][day] = render_day
     coef = 1.2
     for day in self.render_data['odd_days']:
         for pair in day['pairs']:
             pair.from_up = 40 + int(
                 timezone.gettimediff(pair.start_time,
                                      min_start_time).seconds / 60 / coef)
             pair.height = int(pair.duration / coef)
         day['height'] = 40 + int(
             timezone.gettimediff(max_end_time, min_start_time).seconds /
             60 / coef) + 40
     self.render_data['even_days'] = [None] * 6
     min_start_time = timezone.timefromstr("23:59")
     max_end_time = timezone.timefromstr("00:00")
     for day in xrange(7, 13):
         pairs_qry = DefaultPair.query(DefaultPair.week_day == day,
                                       DefaultPair.group_id == group_id).\
             order(DefaultPair.start_time)
         render_day = {
             'week_day':
             day,
             'pairs': [],
             'pair_add_link':
             '/' + group_id + '/new_default_pair?weekday=' + str(day) +
             '&return_url=/' + group_id + '/schedule'
         }
         for pair in pairs_qry:
             pair.edit_link = '/' + group_id + '/edit_default_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             pair.delete_link = '/' + group_id + '/delete_pair?key=' + pair.key.urlsafe() +\
                 '&return_url=/' + group_id + '/schedule'
             min_start_time = min(min_start_time, pair.start_time)
             max_end_time = max(
                 max_end_time,
                 timezone.addtime(
                     pair.start_time,
                     timezone.timedelta(minutes=pair.duration)))
             render_day['pairs'].append(pair)
         self.render_data['even_days'][day - 7] = render_day
     for day in self.render_data['even_days']:
         for pair in day['pairs']:
             pair.from_up = 40 + int(
                 timezone.gettimediff(pair.start_time,
                                      min_start_time).seconds / 60 / coef)
             pair.height = int(pair.duration / coef)
         day['height'] = 40 + int(
             timezone.gettimediff(max_end_time, min_start_time).seconds /
             60 / coef) + 40
     self.response.write(template.render(self.render_data))
Exemple #42
0
 def get(self, *args, **kwargs):
     if not super(ShowSchedule, self).get(*args, **kwargs):
         return
     group_id = kwargs.get('group_id')
     template = JINJA_ENVIRONMENT.get_template('templates/schedule.html')
     schedule_to_render = memcache.get("schedule_to_render_" + group_id)
     date_in_memcache = memcache.get("schedule_set_date_" + group_id)
     if (schedule_to_render is None) or (date_in_memcache is None)\
             or (date_in_memcache != timezone.today()):
         schedule_to_render = [None] * 6
         min_start_time = timezone.timefromstr("23:59")
         max_end_time = timezone.timefromstr("00:00")
         for day in xrange(7):
             today = timezone.today()
             thatday = today + datetime.timedelta(days=day)
             if thatday.weekday() == 6:
                 continue
             pairs_qry = ScheduledPair.query(ScheduledPair.date ==
                                             thatday,
                                             ScheduledPair.group_id ==
                                             group_id).\
                 order(ScheduledPair.start_time)
             render_day = {'week_day': thatday.weekday(),
                           'pairs': [],
                           'date': thatday,
                           'is_current': (today == thatday),
                           'pair_add_link': '/' + group_id +\
                                 '/new_pair?date=' +\
                                 str(thatday) +\
                                 '&return_url=/' + group_id + '/'}
             for pair in pairs_qry:
                 pair_dict = pair.to_dict()
                 pair_dict['edit_link'] = '/' + group_id +\
                      '/edit_pair?key=' +\
                      pair.key.urlsafe() +\
                     '&return_url=/' + group_id + '/'
                 pair_dict['delete_link'] = '/' + group_id +\
                     '/delete_pair?key=' + pair.key.urlsafe() +\
                     '&return_url=/' + group_id + '/'
                 subject = Subject.query(Subject.classname == pair.classname).get()
                 if subject is None:
                     pair_dict['subject_link'] = ''
                 else:
                     pair_dict['subject_link'] = '/' + group_id +\
                         '/subject?key=' + subject.key.urlsafe()
                 render_day['pairs'].append(pair_dict)
                 min_start_time = min(min_start_time, pair.start_time)
                 max_end_time = max(max_end_time,
                                    timezone.addtime(pair.start_time, timezone.timedelta(minutes=pair.duration)))
             schedule_to_render[thatday.weekday()] = render_day
         coef = 1.2 # mins per pixel
         for day in schedule_to_render:
             for pair in day['pairs']:
                 pair['from_up'] = 40 + int(timezone.gettimediff(pair['start_time'], min_start_time).seconds / 60 / coef)
                 pair['height'] = int(pair['duration'] / coef)
             day['height'] = 40 + int(timezone.gettimediff(max_end_time, min_start_time).seconds / 60 / coef) + 40
         memcache.set(key="schedule_to_render_" + group_id,
                      value=schedule_to_render)
         memcache.set(key="schedule_set_date_" + group_id,
                      value=timezone.today())
     self.render_data['days'] = schedule_to_render
     self.response.write(template.render(self.render_data))