Esempio n. 1
0
 def welcome(self):
     identity = request.environ.get("repoze.who.identity")
     if not identity:
         abort(401)
     
     came_from = request.params.get('came_from', '') or "/"
     if identity:
         # Login succeeded
         userid = identity['repoze.who.userid']
         user_det = get_mediator_details(userid)
         if user_det['name']:
             session['user_name'] = user_det['name']
         if user_det['uri']:
             session['user_uri'] = str(user_det['uri'])
         session['user_id'] = userid
         session.save()
         return redirect(came_from, code=303)
     else:
         # Login failed
         try:
             login_counter = request.environ['repoze.who.logins'] + 1
         except:
             login_counter = 0
         destination = "/login?came_from=%s&logins=%s" % (came_from, login_counter)
         return redirect(destination, code=303)
Esempio n. 2
0
    def publish(self):
        identity = request.environ.get("repoze.who.identity")
        if identity:
            #Get list of vocabularies created by userid
            c.userid = identity['repoze.who.userid']
            c.user_det = get_mediator_details(c.userid)
            vocabs = get_mediator_vocabs(c.userid)
            #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
            c.vocab_list = {}

            for k, v in vocabs.iteritems():
                files = get_vocab_files(k)
                description = {}
                for f, vals in files.iteritems():
                    if vals['format'] == 'application/rdf+xml':
                        description = get_vocab_description(vals['path'], k)
                msgs = get_vocab_editorial_note(k)
                c.vocab_list[k] = description
                c.vocab_list[k]['files'] = files
                c.vocab_list[k]['uri'] = v[0]
                c.vocab_list[k]['svn'] = v[1]
                c.vocab_list[k]['note'] = msgs
            return render('/publish.html')
        else:
            session[
                'login_flash'] = "Please login to view vocabularies published and managed by you and to upload new vocabularies"
            session.save()
            destination = "/login?came_from=publish"
            return redirect(destination, code=303)
Esempio n. 3
0
    def welcome(self):
        identity = request.environ.get("repoze.who.identity")
        if not identity:
            abort(401)

        came_from = request.params.get('came_from', '') or "/"
        if identity:
            # Login succeeded
            userid = identity['repoze.who.userid']
            user_det = get_mediator_details(userid)
            if user_det['name']:
                session['user_name'] = user_det['name']
            if user_det['uri']:
                session['user_uri'] = str(user_det['uri'])
            session['user_id'] = userid
            session.save()
            return redirect(came_from, code=303)
        else:
            # Login failed
            try:
                login_counter = request.environ['repoze.who.logins'] + 1
            except:
                login_counter = 0
            destination = "/login?came_from=%s&logins=%s" % (came_from,
                                                             login_counter)
            return redirect(destination, code=303)
Esempio n. 4
0
    def publish(self):
        identity = request.environ.get("repoze.who.identity")
        if identity:
            #Get list of vocabularies created by userid
            c.userid = identity['repoze.who.userid']
            c.user_det = get_mediator_details(c.userid)
            vocabs = get_mediator_vocabs(c.userid)
            #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
            c.vocab_list = {}

            for k, v in vocabs.iteritems():
                files = get_vocab_files(k)
                description = {}
                for f, vals in files.iteritems():
                    if vals['format'] == 'application/rdf+xml':
                        description = get_vocab_description(vals['path'], k)
                msgs = get_vocab_editorial_note(k)
                c.vocab_list[k] = description
                c.vocab_list[k]['files'] = files
                c.vocab_list[k]['uri'] = v[0]
                c.vocab_list[k]['svn'] = v[1]
                c.vocab_list[k]['note'] = msgs
            return render('/publish.html')
        else:
            session['login_flash'] = "Please login to view vocabularies published and managed by you and to upload new vocabularies"
            session.save()
            destination = "/login?came_from=publish"
            return redirect(destination, code=303)
Esempio n. 5
0
 def update(self):
     identity = request.environ.get("repoze.who.identity")
     if not identity:
         came_from = "/update"
         session['login_flash'] = "Please login to update your details"
         session.save()
         destination = "/login?came_from=%s" % came_from
         return redirect(destination, code=303)
     userid = identity['repoze.who.userid']
     #if not (identity['repoze.who.userid'] == userid):
     #    session['browse_flash'] = "You are not authorized to change the registration details for %s"%userid
     #    session.save()
     #    return redirect(url(controller='vocabs', action='index'), code=303)
     params = request.POST
     if not ('firstname' in params and params['firstname']) and \
        not ('lastname' in params and params['lastname']) and \
        not ('email' in params and params['email']) and \
        not ('dept' in params and params['dept']) and \
        not ('password' in params and params['password']):
         c.userid = userid
         c.user_det = get_mediator_details(c.userid)
         return render('/update.html')
     if not ('username' in params
             and params['username']) or not (params['username'] == userid):
         c.message = "The userid on record did not match the one sent"
         c.userid = userid
         c.user_det = get_mediator_details(c.userid)
         return render('/update.html')
     if 'username' in params and params['username'] and \
        'password' in params and params['password']:
         ag.passwdfile.update(params['username'], params['password'])
         ag.passwdfile.save()
     #Write user metadata and save the rdf file
     update_mediator(params)
     c.message = "Your details have been updated!"
     c.userid = userid
     c.user_det = get_mediator_details(c.userid)
     return render('/update.html')
Esempio n. 6
0
 def update(self):
     identity = request.environ.get("repoze.who.identity")
     if not identity:
         came_from = "/update"
         session['login_flash'] = "Please login to update your details"
         session.save()
         destination = "/login?came_from=%s"%came_from
         return redirect(destination, code=303)
     userid = identity['repoze.who.userid']
     #if not (identity['repoze.who.userid'] == userid):
     #    session['browse_flash'] = "You are not authorized to change the registration details for %s"%userid
     #    session.save()
     #    return redirect(url(controller='vocabs', action='index'), code=303)
     params = request.POST
     if not ('firstname' in params and params['firstname']) and \
        not ('lastname' in params and params['lastname']) and \
        not ('email' in params and params['email']) and \
        not ('dept' in params and params['dept']) and \
        not ('password' in params and params['password']):
        c.userid = userid
        c.user_det = get_mediator_details(c.userid)
        return render('/update.html')
     if not ('username' in params and params['username']) or not (params['username'] == userid):
        c.message = "The userid on record did not match the one sent"
        c.userid = userid
        c.user_det = get_mediator_details(c.userid)
        return render('/update.html')
     if 'username' in params and params['username'] and \
        'password' in params and params['password']:
         ag.passwdfile.update(params['username'], params['password'])
         ag.passwdfile.save()
     #Write user metadata and save the rdf file
     update_mediator(params)
     c.message = "Your details have been updated!"
     c.userid = userid
     c.user_det = get_mediator_details(c.userid)
     return render('/update.html')
Esempio n. 7
0
 def owner(self, owner_uuid):
     c.user_det = get_mediator_details(owner_uuid)
     c.vocab_list = {}
     if 'userid' in c.user_det and c.user_det['userid']:
         c.userid = c.user_det['userid']
         vocabs = get_mediator_vocabs(c.userid)
         #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
         for k, v in vocabs.iteritems():
             files = get_vocab_files(k)
             description = {}
             for f, vals in files.iteritems():
                 if vals['format'] == 'application/rdf+xml':
                     description = get_vocab_description(vals['path'], k)
             c.vocab_list[k] = description
             c.vocab_list[k]['files'] = files
     return render('/owner.html')
Esempio n. 8
0
 def owner(self, owner_uuid):
     c.user_det = get_mediator_details(owner_uuid)
     c.vocab_list = {}
     if 'userid' in c.user_det and c.user_det['userid']:
         c.userid = c.user_det['userid']
         vocabs = get_mediator_vocabs(c.userid)
         #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
         for k, v in vocabs.iteritems():
             files = get_vocab_files(k)
             description = {}
             for f, vals in files.iteritems():
                 if vals['format'] == 'application/rdf+xml':
                     description = get_vocab_description(vals['path'], k)
             c.vocab_list[k] = description
             c.vocab_list[k]['files'] = files
     return render ('/owner.html')