Exemplo n.º 1
0
def perfwks():
    d = {}
    if request.method == 'GET':
        # Determine if asking for specific fwk or not
        uri = request.args.get('uri', None)
        d['error'] = request.args.get('error', None)
        if uri:
            d = {}
            if current_user.is_authenticated():
                username = current_user.id
                user = models.getUserProfile(username)            
                d['registered'] = str(hash(uri)) in user['perfwks'].keys()

            d['uri'] = uri
            d['fwk'] = models.getPerformanceFramework(uri)
            return render_template('perfwk-details.html', **d)
        d['frameworks_form'] = FrameworksForm()
    else:
        # Validate submitted fwk uri/parse/add to system
        ff = FrameworksForm(request.form)
        if ff.validate_on_submit():
            #add to system
            competency.parseComp(ff.framework_uri.data)
            d['frameworks_form'] = FrameworksForm()
        else:
            d['frameworks_form'] = ff

    d['pfwks'] = models.findPerformanceFrameworks()
    return render_template('performancefwks.html', **d)
Exemplo n.º 2
0
def me():
    username = current_user.id
    user = models.getUserProfile(username)
    user_comps = user['competencies'].values()
    user_fwks = user['compfwks'].values()
    user_pfwks = user['perfwks'].values()

    # Calculate complete competencies for users and return count
    completed_comps = sum(1 for c in user_comps if c.get('completed',False))
    started_comps = len(user_comps) - completed_comps   
    name = user['first_name'] + ' ' + user['last_name']

    mozilla_asserts = []
    for perf in user_comps:
        moz_dict = {}
        moz_dict['asserts'] = []
        moz_dict['badges'] = []
        moz_dict['title'] = perf['title']
        if 'performances' in perf:
            for p in perf['performances']:
                if 'badgeassertionuri' in p:
                    moz_dict['asserts'].append(p['badgeassertionuri'])
                if 'badgeclassimageurl' in p:
                    moz_dict['badges'].append(p['badgeclassimageurl'])
        mozilla_asserts.append(moz_dict)

    return render_template('me.html', comps=user_comps, fwks=user_fwks, pfwks=user_pfwks, completed=completed_comps, started=started_comps, name=name,
        email=user['email'], mozilla_asserts=mozilla_asserts)
Exemplo n.º 3
0
 def _config(self):
     self.fwkobj = models.getPerformanceFramework(self.uri)
     self.userobj = models.getUserProfile(self.username)
     self.actor = '{"mbox": "mailto:%s"}' % self.userobj['email']
     # tetris doesn't use expapi
     self.verb = 'http://adlnet.gov/xapi/verbs/completed'
     self.query_string = '?agent={0}&verb={1}&activity={2}&related_activities={3}'
     if self.userobj['lrsprofiles']:
         self.profiles = self.userobj['lrsprofiles']
     else:
         self.profiles = [current_app.config['DEFAULT_PROFILE']]
Exemplo n.º 4
0
def me_perfwks():
    username = current_user.id
    user = models.getUserProfile(username)

    uri = request.args.get('uri', None)
    if uri:
        d = {}
        d['uri'] = uri
        d['fwk'] = models.getPerfwkFromUserProfile(user, uri)
        return render_template('me_perfwk-details.html', **d)
    else:
        abort(404)
Exemplo n.º 5
0
def me_competencies():
    username = current_user.id
    user = models.getUserProfile(username)

    d = {}
    uri = request.args.get('uri', None)

    if uri:      
        d['uri'] = uri
        comp = models.getCompFromUserProfile(user, uri)
        d['comp'] = comp
        return render_template('me_comp-details.html', **d)

    d['comps'] = models.GetAllCompsFromUserProfile(user)
    return render_template('me_competencies.html', **d)
Exemplo n.º 6
0
def frameworks():
    if request.method == 'GET':
        # Determine if requesting specific fwk or not
        uri = request.args.get('uri', None)
        if uri:
            d = {}
            if current_user.is_authenticated():
                username = current_user.id
                user = models.getUserProfile(username)            
                d['registered'] = str(hash(uri)) in user['compfwks'].keys()

            d['uri'] = uri
            
            fwk = models.getCompetencyFramework(uri)
            for c in fwk['competencies']:
                compuri = c['uri']
                comp = models.getCompetency(compuri, objectid=True)
                if comp:
                    cid = comp['_id']
                    if 'adlnet' in compuri:
                        compuri = compuri[:7] + 'www.' + compuri[7:]
                        url = "https://node01.public.learningregistry.net/slice?any_tags=%s" % compuri
                        resp = requests.get(url)
                        ids = []
                        if resp.status_code == 200:
                            lrresults = json.loads(resp.content)
                            ids = [s['doc_ID'] for s in lrresults['documents']]
                            for d_id in ids:
                                models.updateCompetencyLR(cid, LR_NODE + d_id + '&by_doc_ID=T')

            d['fwk'] = models.getCompetencyFramework(uri)
            return render_template('compfwk-details.html', **d)

        return_dict = {'frameworks_form': FrameworksForm()}
    else:
        # Validate submitted fwk uri/parse/add to system
        ff = FrameworksForm(request.form)
        if ff.validate_on_submit():
            #add to system
            competency.parseComp(ff.framework_uri.data)
            return_dict = {'frameworks_form': FrameworksForm()}
        else:
            return_dict = {'frameworks_form': ff}

    return_dict['cfwks'] = models.findCompetencyFrameworks()
    return render_template('frameworks.html', **return_dict)
Exemplo n.º 7
0
def competencies():
    # Look for comp args, if none display all comps
    d = {}
    uri = request.args.get('uri', None)
    mb = request.args.get('mb', False)
    
    if uri:      
        if current_user.is_authenticated():
            username = current_user.id
            user = models.getUserProfile(username)            
            d['registered'] = str(hash(uri)) in user['competencies'].keys()

        d['uri'] = uri
        comp = models.getCompetency(uri, objectid=True)
        d['cid'] = comp.pop('_id')
        d['comp'] = comp
        # If medbiq comp display xml if so since it's the original and not lossy internal one
        if mb:
            if not comp.get('edited', False) and competency.isMB(comp):
                try:
                    thexml = requests.get(competency.addXMLSuffix(comp['uri'])).text
                except:
                    thexml = mbc.toXML(comp)
            else:
                thexml = mbc.toXML(comp)
            return Response(thexml, mimetype='application/xml')
        else:
            compuri = d['uri']
            if 'adlnet' in d['uri']:
                compuri = compuri[:7] + 'www.' + compuri[7:]
            url = "https://node01.public.learningregistry.net/slice?any_tags=%s" % compuri
            resp = requests.get(url)
            ids = []
            if resp.status_code == 200:
                lrresults = json.loads(resp.content)
                ids = [s['doc_ID'] for s in lrresults['documents']]
                for d_id in ids:
                    models.updateCompetencyLR(d['cid'], LR_NODE + d_id + '&by_doc_ID=T')
                updated_comp = models.getCompetency(uri, objectid=True)
                d['comp'] = updated_comp

            return render_template('comp-details.html', **d)

    d['comps'] = models.findCompetencies()
    return render_template('competencies.html', **d)
Exemplo n.º 8
0
def getUserProfilePage(userid):
    if userid<=0:
        return None;
    else:
        from models import followerCount,followingCount,postCount,getUserPosts,getUserProfile,getUserProfilePhoto
        from enrichlist import UserContent, richUserPictures
        userProfile = getUserProfile(userid)
        followers = followerCount(userid)
        followings = followingCount(userid)
        posts = postCount(userid)
        favorites = getUserFavorite(userid)
        userPosts = getUserPosts(userid)
        userProfilePhoto = getUserProfilePhoto(userid)
        feeds=list()
        if (userPosts is not None):
            content = richUserPictures(userPosts,userid)
            feeds.extend(generateFeeds(content.pics))
        result = dict(userProfile=userProfile,userProfileUrl=userProfilePhoto,followers=followers,followings=followings,posts=posts, favorites=favorites,userFeeds=feeds)
        return result
Exemplo n.º 9
0
def getUserProfilePage(userid):
    if userid<=0:
        return None;
    else:
        from models import followerCount,followingCount,postCount,getUserPosts,getUserProfile,getUserProfilePhoto
        from enrichlist import UserContent, richUserPictures
        userProfile=getUserProfile(userid)
        followers=followerCount(userid)
        followings=followingCount(userid)
        posts=postCount(userid)
        favorites=getUserFavorite(userid)
        userPosts=getUserPosts(userid)
        userProfilePhoto=getUserProfilePhoto(userid)
        feeds=list()
        if (userPosts is not None):
            content = richUserPictures(userPosts,userid)
        for pic in content.pics:
            feed = dict(picid=pic.pic_id, picuid=pic.pic_uid, username=pic.pic_userName, url=pic.pic_url, time=pic.pic_time, comments=pic.commentList, likeCount=pic.likeCount, liked=pic.liked)
            feeds.append(feed)
        result=dict(userProfile=userProfile,userProfileUrl=userProfilePhoto,followers=followers,followings=followings,posts=posts, favorites=favorites,userFeeds=feeds)
        return result
Exemplo n.º 10
0
	def job(self):
		warninadvance = {'appointments':timedelta(4), 'tasks':timedelta(3) }
		for user in User.objects.filter(is_active=True):
			profile = getUserProfile(user)
			if profile.send_Reminder_Email():
				appointments = [ i for i in Appointment.objects.filter(User=user, End__gt=datetime.now(), Start__lt=datetime.now()+timedelta(profile.AppointmentReminderEmailDaysWarnings)).order_by('Start') if i.isLinkedToIntrestingThing()]
				tasks = [ i for i in Task.objects.filter(User=user, End__lt=datetime.now()+timedelta(profile.TaskReminderEmailDaysWarnings), IsCompleted=False).order_by('End') if i.isLinkedToIntrestingThing()]
				if appointments or tasks:
					if user.first_name or user.last_name:
						body = "Dear "+user.first_name +" "+ user.last_name+",\n\n"
					else:
						body = "Dear "+user.username+",\n\n"
					if appointments:
						if len(appointments) == 1:
							body =  body +"You have the following appointment coming up soon:\n\n"
						else:
							body =  body +"You have the following appointments coming up soon:\n\n"
						for appointment in appointments:
							body = body + appointment.Note + "\n\n"
							if appointment.Start.date() != appointment.End.date():
								body = body + "    "+ appointment.Start.strftime("%a %e %b %l:%M %P") + " to " + appointment.End.strftime("%a %e %b %l:%M %P") + "\n"
							else:
								body = body + "    "+ appointment.Start.strftime("%a %e %b %l:%M %P") + " to " + appointment.End.strftime("%l:%M %P") + "\n"
							body = body + "    View details: http://www.myjobseek.net" +appointment.get_absolute_url() + "\n\n"
					if tasks:
						if len(tasks) == 1:
							body =  body +"You have the following task due soon or overdue:\n\n"
						else:
							body =  body +"You have the following tasks due soon or overdue:\n\n"
						for task in tasks:
							body = body + task.Note + "\n\n"
							if task.Start > datetime.now():
								body = body + "    Not meant to be done until: "+ task.Start.strftime("%a %e %b %l:%M %P") + "\n"
							body = body + "    Due: "+ task.End.strftime("%a %e %b %l:%M %P") + "\n"
							body = body + "    View details: http://www.myjobseek.net" +task.get_absolute_url() + "\n\n"
					body = body + "You currently receive emails:\n" + profile.reminder_emails_string()  + "\n(But only if there is anything to remind you of)\n\n"
					body = body + "You can change this and other settings in your profile:\nhttp://www.myjobseek.net/myprofile/\n\n"
					body = body + "Please leave your feedback on myJobSeek by visiting:\nhttp://www.myjobseek.net/contact/\n\nThanks, \nmyJobSeek"
					print body
					user.email_user("Your upcoming appointments or tasks on myjobseek.net", body)