def get(self): from models import MajorRequirements, Course filename = 'resources/cmps_major.txt' file = open(filename) major = 'CMPS' db.delete(MajorRequirements.all()) skip_flag = False for line in file.readlines(): if line[0] == '\n': continue if line[0] == '#': continue if line[0] == '-': skip_flag = True; if skip_flag == True: skip_flag = False continue course = Course.gql("WHERE number='{}'".format(line.strip())).get() if course == None: continue requirement = MajorRequirements(major=major, course=course) requirement.put() requirements = MajorRequirements.all().fetch(limit=100) self.response.write('<br><br>'.join(map(repr, requirements)))
def get(self): from models import MajorRequirements, Progress, Course from datetime import date import itertools import operator user = users.get_current_user() name = "none" if user: logURL = (users.create_logout_url("/")) name = user.nickname() is_logged_in = True else: logURL = ("/login") is_logged_in = False return redirect ('/login') userQuery = User.gql("WHERE name='{}'".format(user.nickname())).get() major1 = userQuery.major1 major2 = userQuery.major2 major3 = userQuery.major3 minor1 = userQuery.minor1 minor2 = userQuery.minor2 minor3 = userQuery.minor3 m1prog = "30"; m2prog = "20"; m3prog = "10"; mi1prog = "10"; mi2prog = "15"; mi3prog = "50"; requirements = MajorRequirements.all().filter('major =', 'CMPS').fetch(limit=100) requirements = [course.course for course in requirements] completed1 = Progress.all().filter('user ='******'year').order('quarter').fetch(limit=100) completed = [course.course for course in completed1] # any(quarter == chances.quarter for chances in progCheck): available = ['{}-{}'.format(course.number, course.name[:40]) for course in requirements if course not in completed] maxyear = date.today().year + 5 # years = tuple((str(n-1), str(n)) for n in range(date.today().year, date.today().year + 5)) years = list((str(n-1) + " - " + str(n)) for n in range(date.today().year, date.today().year + 5)) # shortyears = list(years) shortyears = list(("Fall" + str(n-1)[2:], "Winter" + str(n)[2:], "Spring" + str(n)[2:], "Summer" + str(n)[2:]) for n in range(date.today().year, date.today().year + 5)) shortyears2 = list((str(n-1)[2:]) for n in range(date.today().year, date.today().year + 5)) quarterlist = [ "Fall", "Winter", "Spring", "Summer"] # prog2 = Progress.all().filter('user ='******'user ='******'quarter =', quarter) prog2 = prog2.filter('year =', int(year)) prog2 = prog2.fetch(limit=10) prog2 = [course1.course.number for course1 in prog2] classes = [quarter+str(year), prog2] allClasse.append(classes) # year = "20" + str(year) allyears.append([year,allClasse]) # completed1 = Progress.all().filter('user ='******'{}{}-{}'.format(course1.quarter, course1.year, course1.course.number) for course1 in completed1) # curr = list((course1.quarter, course1.year, course1.course.number) for course1 in completed1) # curr2 = list() # for key,group in itertools.groupby(curr,operator.itemgetter(0)): # curr2.append((list(group))) # curr =curr2 # curr3 = [] # for listy in curr2: # list1 = [] # for tup in listy: # list1.append(listy[0]) # curr3.append(list1) # curr = curr3 Fall12Classes = tuple(("AMS20", "CMPS101","CMPE100")) Winter13Classes = tuple(("AMS20", "CMPS101","CMPE100")) # shortyears = zip(shortyears,curr) # shortyears = zip(years,shortyears) # year = curr logging = str(allyears) # maxyear = max(maxyear, maxyear2) # logging.debug(maxyear) output = { 'quarterlist': quarterlist, 'logging': logging, 'allyears': allyears, 'major1': major1, 'major2': major2, 'major3': major3, 'minor1': minor1, 'minor2': minor2, 'minor3': minor3, 'm1prog': m1prog, 'm2prog': m2prog, 'm3prog': m3prog, 'mi1prog': mi1prog, 'mi2prog': mi2prog, 'mi3prog': mi3prog, 'years': years, 'shortyears': shortyears, 'logURL': logURL, 'is_logged_in': is_logged_in, 'name': name, 'available': available, } path = os.path.join(os.path.dirname(__file__), 'templates/dashboard.html') self.response.write(template.render(path, output))