Exemplo n.º 1
0
def get_context():
    if permissions.has_admin_permissions():
        projects = projects_service.open_projects()
    else:
        projects = get_open_projects()

    persons_service.clear_person_cache()
    asset_types = assets_service.get_asset_types()
    custom_actions = custom_actions_service.get_custom_actions()
    persons = persons_service.get_persons(
        minimal=not permissions.has_manager_permissions())
    notifications = get_last_notifications()
    project_status_list = projects_service.get_project_statuses()
    task_types = tasks_service.get_task_types()
    task_status_list = tasks_service.get_task_statuses()
    search_filters = get_filters()

    return {
        "asset_types": asset_types,
        "custom_actions": custom_actions,
        "notifications": notifications,
        "persons": persons,
        "project_status": project_status_list,
        "projects": projects,
        "task_types": task_types,
        "task_status": task_status_list,
        "search_filters": search_filters,
    }
Exemplo n.º 2
0
 def post_update(self, instance_dict):
     persons_service.clear_person_cache()
     index_service.remove_person_index(instance_dict["id"])
     person = persons_service.get_person_raw(instance_dict["id"])
     if person.active:
         index_service.index_person(person)
     instance_dict["departments"] = [
         str(department.id) for department in self.instance.departments
     ]
     return instance_dict
Exemplo n.º 3
0
    def test_unactive(self):
        self.person.update({"active": False})
        self.post("auth/login", self.credentials, 400)

        self.person.update({"active": True})
        self.person.save()
        persons_service.clear_person_cache()
        tokens = self.post("auth/login", self.credentials, 200)
        headers = self.get_auth_headers(tokens)
        headers["Content-type"] = "application/json"
        self.assertIsAuthenticated(tokens)
        self.app.get("data/persons/", headers=headers)
        self.app.put("data/persons/%s" % self.person_dict["id"],
                     data=json.dumps({"active": False}),
                     headers=headers)
        self.assertIsNotAuthenticated(tokens)
Exemplo n.º 4
0
 def post_delete(self, instance_dict):
     persons_service.clear_person_cache()
     return instance_dict
Exemplo n.º 5
0
 def post_update(self, instance_dict):
     persons_service.clear_person_cache()
     instance_dict["departments"] = [
         str(department.id) for department in self.instance.departments
     ]
     return instance_dict