示例#1
0
    def GET(self, domain):
        if logman.LoggedIn() == True:
            if qv_domains.is_domain(domain):
                n_group = qv_domains.get_n_groups(domain)

                recs = usrman.get_usr_list()
                usrs = []
                for r in recs:
                    usrs.append(r["Username"])
                if qv_domains.Access_domain(
                        domain,
                        web.cookies().get('QV_Usr')) == "Coord":
                    return renderer.manage(
                        config.base_url,
                        domain,  # name of domain to manage (string)
                        True,  # is user logged in? (boolean)
                        logman.isAdmin(),  # is user and Admin? (boolean)
                        "Coord",  # Access that user has to domain (string)
                        qv_domains.get_list_of_editors(
                            domain
                        ),  # list of editors for domain (string[] / None)
                        None,  # list of coordinators for domain (string[] / None)
                        usrs,
                        n_group,
                        config.base_url + domain + '/view?magic=' +
                        qv_domains.get_admin_url(domain))
                if logman.isAdmin():
                    return renderer.manage(
                        config.base_url,
                        domain,  # name of domain to manage (string)
                        True,  # is user logged in? (boolean)
                        logman.isAdmin(),  # is user and Admin? (boolean)
                        None,  # Access that user has to domain (string)
                        qv_domains.get_list_of_users(
                            domain
                        ),  # list of users for domain (string[[]] / None)
                        None,  # list of coordinators for domain (string[] / None)
                        usrs,
                        n_group,
                        config.base_url + domain + '/view?magic=' +
                        qv_domains.get_admin_url(domain))
                if qv_domains.Access_domain(
                        domain,
                        web.cookies().get('QV_Usr')) == "Editor":
                    return renderer.manage(
                        config.base_url,
                        domain,  # name of domain to manage (string)
                        True,  # is user logged in? (boolean)
                        logman.isAdmin(),  # is user and Admin? (boolean)
                        "Editor",  # Access that user has to domain (string)
                        [""],  # list of editors for domain (string[] / None)
                        None,  # list of coordinators for domain (string[] / None)
                        usrs,
                        n_group)
            else:
                return web.notfound()
        return web.seeother('/login')
示例#2
0
	def POST(self,action,domain):
		if logman.isAdmin():
			# add domain
			if action == "Add":
				# insert new domain
				qv_domains.domain_coll.insert(
					{
						'name': domain,
						'inserted_at': datetime.now(),
	                    'lastActive': datetime.now(),
						'lastEdited': datetime.now(),
						'lastEditedBy': "N/A",
						'admin_url': str(uuid4()),
						'active_question': None,
						'users' : []
					}
				)
				print "created" + domain
				return "success"
			if action == "Remove":
				qv_domains.domain_coll.delete_one({'name': domain})
				print "deleted " + domain
				return "success"
			if action == "Update":
				rec = qv_domains.domain_coll.find_one({'name': domain})
				rec["name"] = domain
				print "changed name to " + domain
				return "success"
		return "failed"
示例#3
0
 def POST(self, action, domain):
     if logman.isAdmin():
         # add domain
         if action == "Add":
             # insert new domain
             qv_domains.domain_coll.insert({
                 'name': domain,
                 'inserted_at': datetime.now(),
                 'lastActive': datetime.now(),
                 'lastEdited': datetime.now(),
                 'lastEditedBy': "N/A",
                 'admin_url': str(uuid4()),
                 'active_question': None,
                 'users': []
             })
             print "created" + domain
             return "success"
         if action == "Remove":
             qv_domains.domain_coll.delete_one({'name': domain})
             print "deleted " + domain
             return "success"
         if action == "Update":
             rec = qv_domains.domain_coll.find_one({'name': domain})
             rec["name"] = domain
             print "changed name to " + domain
             return "success"
     return "failed"
示例#4
0
 def GET(self):
     # get list of domain names
     domain_list = qv_domains.get_list_of_domains()
     if logman.LoggedIn():
         if logman.isAdmin():
             return renderer.home(config.base_url, domain_list, domain_list,
                                  True,
                                  True)  # (domain info, loggedin, isAdmin)
         manage_domain_list = []
         for d in domain_list:
             if qv_domains.Access_domain(
                     d[0],
                     web.cookies().get(
                         'QV_Usr')) == "Coord" or qv_domains.Access_domain(
                             d[0],
                             web.cookies().get('QV_Usr')) == "Editor":
                 manage_domain_list.append([
                     d[0], d[1], d[2],
                     qv_domains.Access_domain(d[0],
                                              web.cookies().get('QV_Usr'))
                 ])
         return renderer.home(config.base_url, domain_list,
                              manage_domain_list, True,
                              False)  # (domain info, loggedin, isAdmin)
     return renderer.home(config.base_url, domain_list, None, False, False)
示例#5
0
	def POST(self,domain):

		data = web.input()
		if logman.LoggedIn():
			# update editors in list
			if qv_domains.Access_domain(domain,web.cookies().get('QV_Usr')) == "Coord":
				if qv_domains.update_list_of_editors(domain,data):
					return "Successful!"
			if logman.isAdmin():
				if qv_domains.update_list_of_all(domain,data):
					return "Admin Successful!"
			return "Failed! You are not logged in!"
示例#6
0
	def GET(self):
		# get list of domain names
		domain_list = qv_domains.get_list_of_domains()
		if logman.LoggedIn():
			if logman.isAdmin():
				return renderer.home(config.base_url,domain_list,domain_list,True,True)	# (domain info, loggedin, isAdmin)
			manage_domain_list = []
			for d in domain_list:
				if qv_domains.Access_domain(d[0],web.cookies().get('QV_Usr')) == "Coord" or qv_domains.Access_domain(d[0],web.cookies().get('QV_Usr')) == "Editor":
					manage_domain_list.append([d[0],d[1],d[2],qv_domains.Access_domain(d[0],web.cookies().get('QV_Usr'))])
			return renderer.home(config.base_url,domain_list,manage_domain_list,True,False) # (domain info, loggedin, isAdmin)
		return renderer.home(config.base_url,domain_list,None,False,False)
示例#7
0
	def GET(self,domain):
		if logman.LoggedIn() == True:
			if qv_domains.is_domain(domain):
				recs = usrman.get_usr_list()
				usrs = []
				for r in recs:
					usrs.append(r["Username"])
				if qv_domains.Access_domain(domain,web.cookies().get('QV_Usr')) == "Coord":
					return renderer.manage(config.base_url,
						domain, 														# name of domain to manage (string)
						True,															# is user logged in? (boolean)
						logman.isAdmin(),												# is user and Admin? (boolean)
						"Coord",														# Access that user has to domain (string)
						qv_domains.get_list_of_editors(domain),							# list of editors for domain (string[] / None)
						None,															# list of coordinators for domain (string[] / None)
						usrs
					)
				if logman.isAdmin():
					return renderer.manage(config.base_url,
						domain, 														# name of domain to manage (string)
						True,															# is user logged in? (boolean)
						logman.isAdmin(),												# is user and Admin? (boolean)
						None,															# Access that user has to domain (string)
						qv_domains.get_list_of_users(domain),							# list of users for domain (string[[]] / None)
						None,															# list of coordinators for domain (string[] / None)
						usrs
					)
				if qv_domains.Access_domain(domain,web.cookies().get('QV_Usr')) == "Editor":
					return renderer.manage(config.base_url,
						domain, 														# name of domain to manage (string)
						True,															# is user logged in? (boolean)
						logman.isAdmin(),												# is user and Admin? (boolean)
						"Editor",														# Access that user has to domain (string)
						[""],															# list of editors for domain (string[] / None)
						None,															# list of coordinators for domain (string[] / None)
						usrs
					)
			else:
				return web.notfound()
		return web.seeother('/login')
示例#8
0
    def GET(self, domain):

        # check logged in
        if not logman.LoggedIn():
            print "Failed Login!"
            return web.seeother('/login')

        # check for valid domain
        if not qv_domains.is_domain(domain):
            print "Failed domain check!"
            return web.notacceptable()

        # check that user has access to this domain
        attempt_at_access = qv_domains.Access_domain(
            domain,
            web.cookies().get('QV_Usr'))
        if logman.isAdmin(
        ) or attempt_at_access == "Coord" or attempt_at_access == "Editor":
            print "Authourized"
        else:
            print "Failed Access!"
            return web.notacceptable()

        qs = qv_questions.find({'domain': domain}).sort([('inserted_at', -1)])

        data = {
            'existing_questions': [],
            'new_uuid':
            uuid4(),
            'domain':
            domain,
            'active_question':
            qv_domains.get_active_question(domain),
            'submit_url':
            glob.urls['question_post']['url_pattern'] % (domain),
            'get_url':
            glob.urls['question_get']['url_pattern'] % (domain, ''),
            'get_results_url':
            glob.urls['results_get']['url_pattern'] % (domain, ''),
            'delete_url':
            glob.urls['answers_post']['url_pattern'] % (domain, ''),
            'results_url':
            glob.urls['view']['url_pattern'] % (domain),
            'history_url':
            glob.urls['history']['url_pattern'] % (domain),
        }

        qsd = [q for q in qs]

        data['existing_questions'] = qsd

        return renderer.editor(config.base_url, data, logman.LoggedIn())
示例#9
0
    def POST(self, domain):

        data = web.input()
        if logman.LoggedIn():
            # update editors in list
            if qv_domains.Access_domain(
                    domain,
                    web.cookies().get('QV_Usr')) == "Coord":
                if qv_domains.update_list_of_editors(domain, data):
                    return "Successful!"
            if logman.isAdmin():
                if qv_domains.update_list_of_all(domain, data):
                    return "Admin Successful!"
            return "Failed! You are not logged in!"
示例#10
0
    def GET(self, domain):

		# check logged in
		if not logman.LoggedIn():
			print "Failed Login!"
			return web.seeother('/login')

		# check for valid domain
		if not qv_domains.is_domain(domain):
			print "Failed domain check!"
			return web.notacceptable()

		# check that user has access to this domain
		attempt_at_access = qv_domains.Access_domain(domain,web.cookies().get('QV_Usr'))
		if logman.isAdmin() or attempt_at_access == "Coord" or attempt_at_access == "Editor":
			print "Authourized"
		else:
			print "Failed Access!"
			return web.notacceptable()


		qs = qv_questions.find({'domain': domain}).sort([('inserted_at', -1)])

		data = {
            'existing_questions': [],
            'new_uuid': uuid4(),
            'domain': domain,
            'active_question': qv_domains.get_active_question(domain),
            'submit_url': glob.urls['question_post']['url_pattern']
            % (domain),
            'get_url': glob.urls['question_get']['url_pattern'] % (domain, ''),
            'get_results_url': glob.urls['results_get']['url_pattern']
            % (domain, ''),
            'delete_url': glob.urls['answers_post']['url_pattern'] % (domain, ''),
            'results_url': glob.urls['view']['url_pattern'] % (domain),
            'history_url': glob.urls['history']['url_pattern'] % (domain),
        }

		qsd = [q for q in qs]

		data['existing_questions'] = qsd

		return renderer.editor(config.base_url,data,logman.LoggedIn())
示例#11
0
	def GET(self):
		if logman.isAdmin():
			return renderer.users(config.base_url,True,usrman.get_usr_list())
		return web.notacceptable()
示例#12
0
 def GET(self):
     if logman.isAdmin():
         return renderer.users(config.base_url, True, usrman.get_usr_list())
     return web.notacceptable()