def add_narrowing_to_member(member, project=None, language=None, added_by=None): """Add a narrowing to the given member for the given project or language. `project` must be a Project object. `language` must be a language code like 'en'. `added_by` must be a TeamMember object. """ if not language: language = '' narrowing = MembershipNarrowing(member=member, project=project, language=language, added_by=added_by) narrowing.save() return narrowing
def _add_language_narrowings(member, languages, author): """Add narrowings on the given member for the given language code strings. Marks them as having come from the given author. """ for language in languages: MembershipNarrowing(language=language, member=member, added_by=author).save()
def _add_project_narrowings(member, project_pks, author): """Add narrowings on the given member for the given project PKs. Marks them as having come from the given author. """ for project_pk in project_pks: project = member.team.project_set.get(pk=project_pk) MembershipNarrowing(project=project, member=member, added_by=author).save()