Skip to content
Snippets Groups Projects

added role column to worker list. Issue #238

Merged Carlos Vega requested to merge feature/238_add_role_column_worker_list into master
1 unresolved thread

See issue #238 (closed) I understand this might be not that useful since this info can be found on the worker details but you can now search for doctors etc. I also did it to understand the way role filters work. I created a property method to access the role. Why is the first role the role of the worker?

Screen_Shot_2018-09-21_at_11.03.15

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
161 161 else:
162 162 return False
163 163
164 @property
165 def role(self):
166 roles = self.roles.filter(study=GLOBAL_STUDY_ID)
167 if roles.count() == 0:
168 return WORKER_STAFF
  • Carlos Vega added 2 commits

    added 2 commits

    Compare with previous version

  • merged

  • Piotr Gawron mentioned in commit 1121aa01

    mentioned in commit 1121aa01

  • @carlos.vega You can also remove this method:

    https://git-r3lab.uni.lu/NCER-PD/scheduling-system/blob/master/smash/web/models/worker.py#L197

    and replace it with newly created role property.

  • Can I? I think it is still required since this method is used by extend_context who has the username but not a Worker. The property role is a property of Worker class, but not from user. So I think we still need the static method either way. However, I simplified the access to the role.

        @staticmethod
        def get_details(the_user):
            persons = Worker.objects.filter(user=the_user)
    
            if len(persons) == 0:
                return the_user.get_full_name(), '<No worker information>'
            else:
                person = persons[0]
                role = "N/A"
                if person.roles.filter(study=GLOBAL_STUDY_ID).count() > 0:
    -              role = person.roles.filter(study=GLOBAL_STUDY_ID)[0].get_role_display()
    +              role = person.role
                return unicode(person), role
  • I think if you combine it with:

        @staticmethod
        def get_by_user(the_user):
            if isinstance(the_user, User):
                workers = Worker.objects.filter(user=the_user)
                if len(workers) > 0:
                    return workers[0]
                else:
                    return None
            elif isinstance(the_user, Worker):
                return the_user
            elif isinstance(the_user, AnonymousUser):
                return None
            elif the_user is not None:
                raise TypeError("Unknown class type: " + the_user.__class__.__name__)
            else:
                return None

    it should work.

  • Okey, to avoid conflicts I created an issue to reduce these duplicities and will take care of that once we merge the branches. It's that okey? #239 (closed)

  • Please register or sign in to reply
    Loading