Commit 169dbe53 authored by Michal Čihař's avatar Michal Čihař

Add wrapper method for adding owner

Issue #1000
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 2a6c249d
...@@ -201,6 +201,10 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -201,6 +201,10 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
group = Group.objects.get(name=self.name) group = Group.objects.get(name=self.name)
user.groups.add(group) user.groups.add(group)
def add_owner(self, user):
"""Adds owner to the project"""
self.owners.add(user)
def remove_user(self, user): def remove_user(self, user):
"""Adds user based on username of email.""" """Adds user based on username of email."""
group = Group.objects.get(name=self.name) group = Group.objects.get(name=self.name)
......
...@@ -53,7 +53,7 @@ def make_owner(request, project): ...@@ -53,7 +53,7 @@ def make_owner(request, project):
obj, form = check_user_form(request, project) obj, form = check_user_form(request, project)
if form is not None: if form is not None:
obj.owners.add(form.cleaned_data['user']) obj.add_owner(form.cleaned_data['user'])
return redirect_param( return redirect_param(
'project', 'project',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment