예제 #1
0
 def get(self):
     logging.info("Starting to clean the datastore")
     courses = Course.query()
     for key in courses.iter(keys_only=True):
         files = File.query(ancestor=key)
         if files.get() is None:
             key.delete()
             logging.info("Deleting: " + key.string_id())
     logging.info("Done cleaning the datastore")
예제 #2
0
 def get(self):
     logging.info("Starting to clean the datastore")
     courses = Course.query()
     for key in courses.iter(keys_only=True):
         files = File.query(ancestor=key)
         if files.get() is None:
             key.delete()
             logging.info("Deleting: " + key.string_id())
     logging.info("Done cleaning the datastore")
예제 #3
0
 def get(self, dept):
     template = main.jinja_env.get_template("templates/main.html")
     values = {
         "departments": models.DEPARTMENT_NAMES,
         "types": models.FILE_TYPES
     }
     values["dept"] = dept
     termcodes = []
     this_year = date.today().year + 1
     this_month = date.today().month
     for year in range(this_year, this_year - 3, -1):
         yearcode = year * 100
         for quarter, value in [('Spring', 30), ("Winter", 20),
                                ("Fall", 10)]:
             termcodes.append({
                 "term":
                 quarter + " " + str(year - 1) + "-" + str(year),
                 "code":
                 yearcode + value
             })
     values["termcodes"] = termcodes
     if 1 <= this_month <= 2:
         # Winter Quarter
         values["termcodes"] = termcodes[4:]
     elif 3 <= this_month <= 6:
         # Spring Quarter
         values["termcodes"] = termcodes[3:]
     elif 7 <= this_month <= 8:
         # Summer
         pass
     elif 9 <= this_month <= 11:
         # Fall Quarter
         values["termcodes"] = termcodes[2:]
     elif this_month == 12:
         # Winter Quarter
         values["termcodes"] = termcodes[1:]
     course_keys = Course.query(Course.department == dept)
     courses = []
     files = {}
     for course_key in course_keys.iter(keys_only=True):
         courses.append(course_key.string_id())
         files[course_key.string_id()] = File.query(ancestor=course_key)
     courses.sort()
     values["courses"] = courses
     values["files"] = files
     self.response.out.write(template.render(values))
예제 #4
0
 def get(self, dept):
     template = main.jinja_env.get_template("templates/main.html")
     values = {"departments": models.DEPARTMENT_NAMES, "types": models.FILE_TYPES}
     values["dept"] = dept
     termcodes = []
     this_year = date.today().year + 1
     this_month = date.today().month
     for year in range(this_year, this_year - 3, -1):
         yearcode = year * 100
         for quarter, value in [('Spring', 30), ("Winter", 20), ("Fall", 10)]:
             termcodes.append({"term":quarter + " " + str(year - 1) + "-" + str(year) ,"code":yearcode + value})
     values["termcodes"] = termcodes
     if 1 <= this_month <= 2:
         # Winter Quarter
         values["termcodes"] = termcodes[4:]
     elif 3 <= this_month <= 6:
         # Spring Quarter
         values["termcodes"] = termcodes[3:]
     elif 7 <= this_month <= 8:
         # Summer
         pass
     elif 9 <= this_month <= 11:
         # Fall Quarter
         values["termcodes"] = termcodes[2:]
     elif this_month == 12:
         # Winter Quarter
         values["termcodes"] = termcodes[1:]
     course_keys = Course.query(Course.department == dept)
     courses = []
     files = {}
     for course_key in course_keys.iter(keys_only=True):
         courses.append(course_key.string_id())
         files[course_key.string_id()] = File.query(ancestor=course_key)
     courses.sort()
     values["courses"] = courses
     values["files"] = files
     self.response.out.write(template.render(values))