Exemple #1
0
def get_managed(value, arg):
    managed_users = ManagedUser.get_managed_users(value)
    donut_vals = []
    if managed_users and len(managed_users) > 0:
        for managed_user in managed_users:
            args = arg.split(" ")
            if args[0] == "track":
                if EnrollProgram.is_enrolled_track(managed_user.user.email, args[1]):
                    enrolled_programs_count = float(len(EnrollProgram.get_enrolled_programs(managed_user.user.email, args[1])))
                    programs_count = float(Program.all().ancestor(Track.get_by_key_name(args[1])).count())
                    score = round((enrolled_programs_count/programs_count)*100,2)
                    engage_score = round(random()*score,0)
                    engage_score = int(engage_score) if engage_score > 1 else 1
                    donut_vals.append((managed_user.user.name,[DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')]))
            elif args[0] == "program":
                if EnrollProgram.is_enrolled_program(managed_user.user.email, args[1], args[2]):
                    track = Track.get_by_key_name(args[2])
                    program = Program.get_by_key_name(args[1], parent=track)
                    modules = ProgramModule.all().ancestor(program).order('name')
                    modules_count = modules.count()*1.0
                    completed_modules = []
                    for module in modules:
                        if module.completed:
                            completed_modules.append(module)
                    completed_modules_count = len(completed_modules)
                    score = (completed_modules_count/modules_count)*100.0
                    engage_score = round(score*random(),0)
                    engage_score = int(engage_score) if engage_score > 1 else 1
                    donut_vals.append((managed_user.user.name,[DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')]))
    return DonutFactory.get_donuts(100, 0.875, donut_vals, 'transparent', '#ddd')
Exemple #2
0
 def get(self):
     track = Track.get_by_key_name(self['track_id'])
     program = Program.get_by_key_name(self['program_id'], parent=track)
     modules = ProgramModule.all().ancestor(program).order('name')
     template_values = {'program':program,
                        'track':track,
                        'modules':modules,
                        'listing_heading':program.name}
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         email = self.session['member']
         member = Member.get_by_email(email)
         template_values['member'] = member
         if member.role == MEMBER_ROLE[MANAGER]:
             template_values['is_manager'] = True
         else:
             modules_count = modules.count()*1.0
             completed_modules = []
             for module in modules:
                 if module.completed:
                     completed_modules.append(module)
             completed_modules_count = len(completed_modules)
             score = (completed_modules_count/modules_count)*100.0
             engage_score = round(score*random(),0)
             engage_score = int(engage_score) if engage_score > 1 else 1
             template_values['donuts'] = DonutFactory.get_donuts(100, 0.875, [('Engineer1', [DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')], '/assets/img/tracks/mobile_dev.png')], 'transparent', '#ddd')
     self.render_template(template_name='program_listing.html', template_values=template_values)
Exemple #3
0
 def get(self):
     template_values = {}
     active_track = self['track_id']
     if active_track:
         template_values['active_track'] = active_track
     template_values['page_title_centered'] = get_page_title_centered_contents()
     template_values['tracks'] = [self._make_json(track) for track in Track.all().order('order')]
     template_values['is_member'] = True if 'member' in self.session else False
     template_values['track_donuts'] = {}
     if 'member' in self.session:
         email = self.session['member']
         member = Member.get_by_email(email)
         template_values['member'] = member
         template_values['enrolled_tracks'] = {}
         for track in Tracks.get_tracks():
             template_values['enrolled_tracks'][track.id] = EnrollProgram.is_enrolled_track(email, track.id)
         if member.role == MEMBER_ROLE[MANAGER]:
             template_values['is_manager'] = True
         else:
             for track in Tracks.get_tracks():
                 enrolled_programs_count = float(len(EnrollProgram.get_enrolled_programs(email, track.id)))
                 programs_count = float(Program.all().ancestor(Track.get_by_key_name(track.id)).count())
                 score = round((enrolled_programs_count/programs_count)*100,2)
                 engage_score = round(random()*score,0)
                 engage_score = int(engage_score) if engage_score > 1 else 1
                 template_values['track_donuts'][track.id] = [Donut(100, 0.875, member.name, [DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')], 'transparent', '#ddd')]
     self.render_template(template_name='tracks.html', template_values=template_values)
Exemple #4
0
 def post(self):
     email = self.session['member']
     track_id = self['track_id']
     program_id = self['program_id']
     program = Program.get_by_key_name(program_id, parent=Track.get_by_key_name(track_id))
     EnrollProgram.create(Member.get_by_email(email), program)
     self.redirect("/tracks/program_listing?program_id=%s&track_id=%s"%(program_id, track_id))
Exemple #5
0
 def _make_json(self, track):
     response = {}
     response['icon'] = track.icon
     response['highlight_icon'] = track.highlight_icon
     response['name'] = track.name
     response['id'] = track.id
     response['programs'] = Program.all().ancestor(track).order('start_date')
     return response
Exemple #6
0
 def post(self):
     track_id = self['track']
     program_id = self['program']
     expert_email = self['expert']
     program = Program.get_by_key_name(program_id, parent=Track.get_by_key_name(track_id))
     program.expert = Expert.get_by_key_name(expert_email)
     program.put()
     self.redirect("/tracks/program_listing?program_id=%s&track_id=%s"%(program_id, track_id))
Exemple #7
0
def get_managed(value, arg):
    managed_users = ManagedUser.get_managed_users(value)
    donut_vals = []
    if managed_users and len(managed_users) > 0:
        for managed_user in managed_users:
            args = arg.split(" ")
            if args[0] == "track":
                if EnrollProgram.is_enrolled_track(managed_user.user.email,
                                                   args[1]):
                    enrolled_programs_count = float(
                        len(
                            EnrollProgram.get_enrolled_programs(
                                managed_user.user.email, args[1])))
                    programs_count = float(Program.all().ancestor(
                        Track.get_by_key_name(args[1])).count())
                    score = round(
                        (enrolled_programs_count / programs_count) * 100, 2)
                    engage_score = round(random() * score, 0)
                    engage_score = int(engage_score) if engage_score > 1 else 1
                    donut_vals.append((managed_user.user.name, [
                        DonutSegment(engage_score, '#1c758a'),
                        DonutSegment(score, '#58c4dd')
                    ]))
            elif args[0] == "program":
                if EnrollProgram.is_enrolled_program(managed_user.user.email,
                                                     args[1], args[2]):
                    track = Track.get_by_key_name(args[2])
                    program = Program.get_by_key_name(args[1], parent=track)
                    modules = ProgramModule.all().ancestor(program).order(
                        'name')
                    modules_count = modules.count() * 1.0
                    completed_modules = []
                    for module in modules:
                        if module.completed:
                            completed_modules.append(module)
                    completed_modules_count = len(completed_modules)
                    score = (completed_modules_count / modules_count) * 100.0
                    engage_score = round(score * random(), 0)
                    engage_score = int(engage_score) if engage_score > 1 else 1
                    donut_vals.append((managed_user.user.name, [
                        DonutSegment(engage_score, '#1c758a'),
                        DonutSegment(score, '#58c4dd')
                    ]))
    return DonutFactory.get_donuts(100, 0.875, donut_vals, 'transparent',
                                   '#ddd')
Exemple #8
0
 def post(self):
     email = self.session['member']
     track_id = self['track_id']
     program_id = self['program_id']
     program = Program.get_by_key_name(
         program_id, parent=Track.get_by_key_name(track_id))
     EnrollProgram.create(Member.get_by_email(email), program)
     self.redirect("/tracks/program_listing?program_id=%s&track_id=%s" %
                   (program_id, track_id))
Exemple #9
0
 def _make_json(self, track):
     response = {}
     response['icon'] = track.icon
     response['highlight_icon'] = track.highlight_icon
     response['name'] = track.name
     response['id'] = track.id
     response['programs'] = Program.all().ancestor(track).order(
         'start_date')
     return response
 def get_enrolled_programs(cls, email, track_id):
     track_programs = Program.all().ancestor(
         Track.get_by_key_name(track_id))
     enrolled_programs = []
     for program in track_programs:
         enrolled_program = EnrollProgram.get_by_key_name(email,
                                                          parent=program)
         if enrolled_program:
             enrolled_programs.append(enrolled_program)
     return enrolled_programs
Exemple #11
0
def setup_modules():
    for track in tracks:
        track_obj = Track.get_by_key_name(track.id)
        for program in track.programs:
            start_date = datetime.now()
            program_obj = Program.get_by_key_name(program.id, parent=track_obj)
            if program.modules:
                for module in program.modules:
                    start_date = start_date + timedelta(days=3)
                    ProgramModule(parent=program_obj, name=module.title, units=module.units, start_date=start_date).put()
Exemple #12
0
 def post(self):
     track_id = self['track']
     program_id = self['program']
     expert_email = self['expert']
     program = Program.get_by_key_name(
         program_id, parent=Track.get_by_key_name(track_id))
     program.expert = Expert.get_by_key_name(expert_email)
     program.put()
     self.redirect("/tracks/program_listing?program_id=%s&track_id=%s" %
                   (program_id, track_id))
Exemple #13
0
 def get(self):
     path = 'associate.html'
     template_values = {}
     template_values['form_url'] = '/api/common/save_association'
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     track_programs = []
     tracks = Track.all()
     for track in tracks:
         programs = Program.all().ancestor(track)
         track_programs.append((track, programs))
     template_values['track_programs'] = track_programs
     template_values['experts'] = Expert.all().fetch(50)
     self.write(self.get_rendered_html(path, template_values), 200)
Exemple #14
0
 def get(self):
     path = 'associate.html'
     template_values = {}
     template_values['form_url'] = '/api/common/save_association'
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     track_programs = []
     tracks = Track.all()
     for track in tracks:
         programs = Program.all().ancestor(track)
         track_programs.append((track, programs))
     template_values['track_programs'] = track_programs
     template_values['experts'] = Expert.all().fetch(50)
     self.write(self.get_rendered_html(path, template_values), 200)
Exemple #15
0
 def get(self):
     template_values = {}
     active_track = self['track_id']
     if active_track:
         template_values['active_track'] = active_track
     template_values[
         'page_title_centered'] = get_page_title_centered_contents()
     template_values['tracks'] = [
         self._make_json(track) for track in Track.all().order('order')
     ]
     template_values[
         'is_member'] = True if 'member' in self.session else False
     template_values['track_donuts'] = {}
     if 'member' in self.session:
         email = self.session['member']
         member = Member.get_by_email(email)
         template_values['member'] = member
         template_values['enrolled_tracks'] = {}
         for track in Tracks.get_tracks():
             template_values['enrolled_tracks'][
                 track.id] = EnrollProgram.is_enrolled_track(
                     email, track.id)
         if member.role == MEMBER_ROLE[MANAGER]:
             template_values['is_manager'] = True
         else:
             for track in Tracks.get_tracks():
                 enrolled_programs_count = float(
                     len(
                         EnrollProgram.get_enrolled_programs(
                             email, track.id)))
                 programs_count = float(Program.all().ancestor(
                     Track.get_by_key_name(track.id)).count())
                 score = round(
                     (enrolled_programs_count / programs_count) * 100, 2)
                 engage_score = round(random() * score, 0)
                 engage_score = int(engage_score) if engage_score > 1 else 1
                 template_values['track_donuts'][track.id] = [
                     Donut(100, 0.875, member.name, [
                         DonutSegment(engage_score, '#1c758a'),
                         DonutSegment(score, '#58c4dd')
                     ], 'transparent', '#ddd')
                 ]
     self.render_template(template_name='tracks.html',
                          template_values=template_values)
Exemple #16
0
 def get(self):
     track = Track.get_by_key_name(self['track_id'])
     program = Program.get_by_key_name(self['program_id'], parent=track)
     modules = ProgramModule.all().ancestor(program).order('name')
     template_values = {
         'program': program,
         'track': track,
         'modules': modules,
         'listing_heading': program.name
     }
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         email = self.session['member']
         member = Member.get_by_email(email)
         template_values['member'] = member
         if member.role == MEMBER_ROLE[MANAGER]:
             template_values['is_manager'] = True
         else:
             modules_count = modules.count() * 1.0
             completed_modules = []
             for module in modules:
                 if module.completed:
                     completed_modules.append(module)
             completed_modules_count = len(completed_modules)
             score = (completed_modules_count / modules_count) * 100.0
             engage_score = round(score * random(), 0)
             engage_score = int(engage_score) if engage_score > 1 else 1
             template_values['donuts'] = DonutFactory.get_donuts(
                 100, 0.875, [('Engineer1', [
                     DonutSegment(engage_score, '#1c758a'),
                     DonutSegment(score, '#58c4dd')
                 ], '/assets/img/tracks/mobile_dev.png')], 'transparent',
                 '#ddd')
     self.render_template(template_name='program_listing.html',
                          template_values=template_values)
Exemple #17
0
def setup_programs():
    for track in tracks:
        track_obj = Track.get_by_key_name(track.id)
        for program in track.programs:
            Program(key_name=program.id, parent=track_obj, image=program.snapshot, slots=program.num_spots , name=program.title, description=program.description, start_date=datetime.strptime(program.start_date, "%b %d %Y")).put()
Exemple #18
0
def register():
    # Output message if something goes wrong...
    msg = ''
    # Check if "username", "password" and "email" POST requests exist (user submitted form)
    if request.method == 'POST' and 'category' in request.form and 'registration_id' in request.form and 'user_name' in request.form and 'password' in request.form and 'email' in request.form and 'phone_number' in request.form and 'first_name' in request.form and 'middle_name' in request.form and 'last_name' in request.form:
        # Create variables for easy access
        username = request.form['user_name']
        password = request.form['password']
        email = request.form['email']
        category = request.form['category']
        registration_id = request.form['registration_id']
        middle_name = request.form['middle_name']
        first_name = request.form['first_name']
        last_name = request.form['last_name']
        phone_number = request.form['phone_number']
        if category == 'student':
            student1 = Student(username, password, phone_number, email,
                               first_name, middle_name, last_name,
                               registration_id)
            # address1 = Address("Distelstraat 6", "Schaerbeek", "Brussels", "Brussels", "Belgium", "1030")
            # program = Program("Masters in Applied Computer Science", "MACS")

            student1.address_id = 1
            student1.program_id = 1
            db.session.add(student1)
            db.session.commit()

    if request.method == 'POST' and 'category' in request.form and 'registration_id' in request.form and 'user_name' in request.form and 'password' in request.form and 'email' in request.form and 'phone_number' in request.form and 'first_name' in request.form:
        # Create variables for easy access
        print('unicheck!!!!!!')
        username = request.form['user_name']
        password = request.form['password']
        email = request.form['email']
        category = request.form['category']
        if category == 'company':
            company_code = request.form['registration_id']
        else:
            university_code = request.form['registration_id']
        name = request.form['first_name']
        phone_number = request.form['phone_number']
        if category == 'company':
            company = Company(username, password, phone_number, email, name,
                              company_code)
            address1 = Address("Distelstraat 6", "Schaerbeek", "Brussels",
                               "Brussels", "Belgium", "1030")
            company.address_id = 1
            db.session.add(company)
            db.session.commit()
            print('commitCHECK!!')

        elif (category == 'university'):
            university = University(username, password, phone_number, email,
                                    name, university_code)
            address3 = Address("Uitbreidingstraat 8", "Berchem", "Antwerp",
                               "Antwerp", "Belgium", "2600")
            program = Program("Masters in Applied Computer Science", "MACS")

            university.address_id = 3
            # university.programs.append(program)
            db.session.add(university)
            db.session.commit()
            print('commitCHECK!!')
    return 'DONE!'
Exemple #19
0
from model.program import Program
from model.student import Student
from model.university import University

from model.university_program import university_program  # Dont remove

db.create_all()
address1 = Address("Distelstraat 6", "Schaerbeek", "Brussels", "Brussels", "Belgium", "1030")
address2 = Address("Hemeryckxlaan 10", "Kontich", "Antwerp", "Antwerp", "Belgium", "2660")
address3 = Address("Uitbreidingstraat 8", "Berchem", "Antwerp", "Antwerp", "Belgium", "2600")
address4 = Address("Celestijnenlaan 69", "", "Leuven", "Vlaams-Brabant", "Belgium", "3000")

company = Company("uza", "password", "+3212345678", "*****@*****.**", "UZA", "CPY1")
company.address = address1

program = Program("Masters in Applied Computer Science", "MACS")

student1 = Student("student1", "password1", "+3245678910", "*****@*****.**", "Jeff", "Ronald", "Bezos", "STU1")
student1.address = address2
student1.program = program

student2 = Student("student2", "password2", "+3244557766", "*****@*****.**", "John", "Bill", "Gates", "STU2")
student2.address = address4
student2.program = program

student3 = Student("student3", "password3", "+3244557786", "*****@*****.**", "Shawn", "James", "Hill", "STU3")
student3.address = address4
student3.program = program

university = University("ua_uni1", "password3", "+32889966771", "*****@*****.**", "UA", "UNI1")
university.address = address3
 def is_enrolled_program(cls, email, program_id, track_id):
     return EnrollProgram.get_by_key_name(
         email,
         parent=Program.get_by_key_name(
             program_id, parent=Track.get_by_key_name(track_id)))