Example #1
0
 def post(self):
     #logging.error('QQQ: templatecreate POST')
     currentuser = users.get_current_user()
     n = UserSuppl(FirstName=self.request.get('FirstName')
               , LastName=self.request.get('LastName')
               , UserID=currentuser
               , Email=self.request.get('Email')
               , Descr=self.request.get('Descr')
               , Status='Pending Assignment'
               )
     n.put()
     return self.redirect('/users/applthks')
Example #2
0
def AccessOK(xCurrentUser, PermissionID):
#    PermissionID = int(PermID)
    currentuser = users.get_current_user()
    logging.info('GGG: PermissionID: %s' % PermissionID)
    logging.info('GGG: current_user_admin: %s' % users.is_current_user_admin())
    IsOK = False
    if users.is_current_user_admin():
        logging.info('GGG: AccessOKNew-Where: %s' % 'In user is Admin user')
        IsOK = True
    else:
        logging.info('GGG: AccessOKNew-Where: %s' % 'In user is Admin user ELSE')
        q = UserSuppl.query(UserSuppl.UserID == currentuser)
        user = q.get()
        if user:
            logging.info('GGG: AccessOKNew-Where: %s' % 'retrieveD UserSuppl')
            logging.info('GGG: UserID: %s' % user.UserID)
            logging.info('GGG: Role: %s' % user.Role)
            if user.Status == 'Assigned':
                if user.Role == 'admin':
                    IsOK = True
                else:
                    if PermissionID in user.Permissions:
                        IsOK = True
#    IsOK = True
#    logging.info('GGG: Final IsOK: %s' % IsOK)
    logging.info('GGG: AccessOKNew-Just before Rtn: %s' % IsOK)
    return IsOK
Example #3
0
    def get(self, role_id):
        RoleListAdmin = [];
        RoleListAdvocate = [110,111,120, 121, 210, 220, 230, 231, 232];
        RoleListTokenBuilder = [110,111,120, 121, 210, 220, 230, 231, 232];
        RoleListTokenTranslator = [110,111,120, 121, 210, 220, 230, 231, 232];
        RolePermissionDict = {}
        RolePermissionDict['admin'] = RoleListAdmin
        RolePermissionDict['advocate'] = RoleListAdvocate
        RolePermissionDict['tokenbuilder'] = RoleListTokenBuilder
        RolePermissionDict['tokentranslator'] = RoleListTokenTranslator
        RolePermissionsList =  RolePermissionDict[role_id]

        q = UserSuppl.query(UserSuppl.Role == role_id, UserSuppl.Status == 'Assigned')
        userx = q.fetch(999)

        currentuser = users.get_current_user()
        logging.info('QQQ: currentuser: %s' % currentuser)

        for user in userx:
            logging.info('QQQ: UserID: %s' % user.UserID)
            logging.info('QQQ: Role: %s' % user.Role)
            PermissionsPrev = user.Permissions
            user.Permissions = RolePermissionsList
            if not user.Permissions == PermissionsPrev:
                user.ChangedBy = currentuser
                user.ChangedDate = datetime.now() 			
            user.put()

#        if currentuser != template.CreatedBy and not users.is_current_user_admin():
#            self.abort(403)
#            return
        return self.redirect('/admin/roles/display/' + role_id)
Example #4
0
 def get(self):
     user = UserSuppl.query()
     logout = None
     login = None
     currentuser = users.get_current_user()
     AlreadyRegistered = False
     if currentuser:
         logout = users.create_logout_url('/users/join' )
         UserRegOK = 'Y'
         q = UserSuppl.query(UserSuppl.UserID == currentuser)
         user = q.get()
         if user:
             AlreadyRegistered = True
     else:
         login = users.create_login_url('/users/join')
         UserRegOK = 'N'
     self.render_template('UserJoin.html', {'UserRegOK': UserRegOK, 'AlreadyRegistered': AlreadyRegistered, 'currentuser':currentuser, 'login':login, 'logout': logout})
Example #5
0
 def get(self):
     user = UserSuppl.query()
     logout = None
     login = None
     currentuser = users.get_current_user()
     if currentuser:
           logout = users.create_logout_url('/users' )
     else:
           login = users.create_login_url('/users')
     self.render_template('UserList.html', {'user': user, 'currentuser':currentuser, 'login':login, 'logout': logout})
Example #6
0
 def get(self):
     user = UserSuppl.query()
     logout = None
     login = None
     currentuser = users.get_current_user()
     if currentuser:
         logout = users.create_logout_url('/users/join' )
         UserRegOK = 'Y'
     else:
         login = users.create_login_url('/users/join')
         UserRegOK = 'N'
     self.render_template('UserJoinThanks.html', {'UserRegOK': UserRegOK, 'currentuser':currentuser, 'login':login, 'logout': logout})
Example #7
0
 def get(self):
     logout = None
     login = None
     currentuser = users.get_current_user()
     if currentuser:
           logout = users.create_logout_url('/users' )
     else:
           login = users.create_login_url('/users/create')
     q = UserSuppl.query(UserSuppl.UserID == currentuser)
     user = q.get()
     if user:
         return self.redirect('/users/join')
     else:
         self.render_template('UserCreate.html', {'currentuser':currentuser, 'login':login, 'logout': logout})
Example #8
0
def UserPermissionsCalc():
	PermissionDict = {}
	PermissionDict[1] = 'Permission to purely administrative functions.'
	PermissionDict[110] = 'Permission to View Papers and Discussion Topics.'
	PermissionDict[111] = 'Permission to Create/Edit Papers and Discussion Topics.'
	PermissionDict[120] = 'Permission to View Comments on Papers and Discussion Topics.'
	PermissionDict[121] = 'Permission to Create/Edit Comments on Papers and Discussion Topics.'
	PermissionDict[210] = 'Permission to View Templates.'
	PermissionDict[211] = 'Permission to Create/Edit Templates.'
	PermissionDict[220] = 'Permission to View Tokens.'
	PermissionDict[221] = 'Permission to Create/Edit English Tokens.'
	PermissionDict[230] = 'Permission to View Foreign Language Tokens.'
	PermissionDict[231] = 'Permission to Clone Foreign Language Tokens.'
	PermissionDict[232] = 'Permission to Translate/Edit Foreign Language Tokens.'
	RoleDict = {}	
	RoleDict['admin'] = 'Has access to everything.'
	RoleDict['tokenbuilder'] = 'Can create Templates and English Tokens plus the permissions of Token-Translator.'
	RoleDict['tokentranslator'] = 'Can create Tokens in any language except English.'
	RoleDict['advocate'] = 'Advocates can create papers and post initial discussion topics.'
	RoleListAdvocate = [110, 111, 120, 121, 210, 220, 230, 231, 232];
	RoleListTokenBuilder = [110, 111, 120, 121, 210, 220, 230, 231, 232];
	RoleListTokenTranslator = [110, 111, 120, 121, 210, 220, 230, 231, 232];
	RolePermissionDict = {}
	RolePermissionDict['advocate'] = RoleListAdvocate
	RolePermissionDict['tokenbuilder'] = RoleListTokenBuilder
	RolePermissionDict['tokentranslator'] = RoleListTokenTranslator

	#TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates')
	jinja_environment = \
		jinja2.Environment(autoescape=False, loader=jinja2.FileSystemLoader(TEMPLATE_DIR))

#        template = jinja_environment.get_template('RDisplay.html')
#        self.response.out.write(template.render(template_values))

	RolePermissionDictYes = {}
	RolePermissionDictNo = {}
	RolePermissionList = RolePermissionDict[role_key]
	logging.info('QQQ: RolePermissionList: %s' % RolePermissionList[0:len(RolePermissionList)])

	for key, value in PermissionDict.items():
		if key in RolePermissionList:
			RolePermissionDictYes[key] = value
		else:
			RolePermissionDictNo[key] = value

	q = UserSuppl.query()
	usersuppl = q.fetch(999)
# this function does not appear to have been completed.
	return
Example #9
0
    def AccessOKNew(Session, PermissionID):
        currentuser = users.get_current_user()
        logging.info('SSS: PermissionID: %s' % PermissionID)
        logging.info('SSS: current_user_admin: %s' % users.is_current_user_admin())
        IsOK = False
        if users.is_current_user_admin():
            logging.info('SSS: AccessOKNew-Where: %s' % 'user is Admin user')
            IsOK = True
        else:
            logging.info('SSS: AccessOKNew-Where: %s' % 'user is Admin user ELSE')
            UserSuppl = session.get('UserSuppl')
            if UserSuppl:
                logging.info('ZZZ: AccessOKNew-Where1: %s' % 'Got UserSuppl from Session')
                if PermissionID in UserSuppl.Permissions:
                    logging.info('SSS: AccessOKNew-Where: %s' % 'Got UserSuppl from Session AND PermissionID is in UserSuppl-Permissions')
                    IsOK = True
            else:
                logging.info('ZZZ: AccessOKNew-Where2: %s' % 'UserSuppl NOT in Session')
                q = UserSuppl.query(UserSuppl.UserID == currentuser)
                UserSuppl = q.get()
                if UserSuppl:
                    logging.info('SSS: AccessOKNew-Where: %s' % 'retrieveD2 UserSuppl')
                    logging.info('SSS: UserID: %s' % UserSuppl.UserID)
                    logging.info('SSS: Role: %s' % UserSuppl.Role)
                    session['UserSuppl'] = UserSuppl
                    if UserSuppl.Status == 'Assigned':
                        logging.info('SSS: AccessOKNew-Where: %s' % 'User status = Assigned')
                        if UserSuppl.Role == 'admin':
                            logging.info('SSS: AccessOKNew-Where: %s' % 'User role = Admin')
                            IsOK = True
                        else:
                            logging.info('SSS: AccessOKNew-Where: %s' % 'User role NOT = Admin')
                            if PermissionID in UserSuppl.Permissions:
                                logging.info('SSS: AccessOKNew-Where: %s' % 'PermissionID in UserSuppl.Permissions')
#                                logging.info('SSS: AccessOKNew-Where: %s' % 'PermissionID in UserSuppl.Permissions')
                                IsOK = True
        logging.info('SSS: AccessOKNew-Just before Rtn: %s' % IsOK)
        return IsOK