Example #1
0
def update_assignee(user):
    if not user.get('role') in authentication.super_roles():
        if not authentication.is_master(user):
            res = _add_assignees_for_user(user)
        else:
            res = _add_assignees_for_master(user)
    else:
        res = _add_assignees_for_super(user)
    return res
Example #2
0
 def index(self):
     if authentication.is_logged_in(cherrypy.session):
         user = authentication.get_current_user()
         if authentication.is_master(user):
             redirect(URL_MASTER)
         else:
             customers = assigneesHandler.get_customers(user.get('username'))
             #Normal users can only be assigned to one customer.
             if customers:
                 customer = customers.pop()
                 redirect(URL_USER + str(customer.get('customer')))
             else:
                 redirect(URL_LOGIN)
     else:
         redirect(URL_LOGIN)
Example #3
0
def get_customers_for(username= None):
    user = userHandler.get_user(username)
    assignees = assigneesHandler.get_customers(user.get('username'))
    customers = []
    if not authentication.is_master(user):
        # admin and user
        if assignees:
            customers.append(get_customer(assignees[0].get('customer')))
            return customers
    else:
        if not authentication.user_is_admin(user):
            # master_user
            for assignee in assignees:
                customers.append(get_customer(assignee.get('customer')))
            return customers
        # super_user and master_admin
        return [{'id': 1, 'name': 'master'}]