Commit 92d22cb3 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

[models] added hook for group membership changes of users

parent d6a76043
......@@ -6,7 +6,7 @@ from sqlalchemy import Column, Table, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.orm.session import object_session
from sqlalchemy.types import Unicode, DateTime, Integer, UnicodeText
from vispa import AjaxException
from vispa import AjaxException, fire_callback
from vispa.models import Base
from vispa.models.project import Project
from vispa.models.user import User
......@@ -331,6 +331,7 @@ class Group(Base):
session.commit()
except:
session.rollback()
fire_callback("user.group.membership", user, self, confirmed == Group_User_Assoc.CONFIRMED)
def confirm_user(self, user):
"""
......@@ -349,6 +350,7 @@ class Group(Base):
if assoc is None:
raise AjaxException('user %s not in group %s' % (user.name, self.name), 409)
assoc.status = Group_User_Assoc.CONFIRMED
fire_callback("user.group.membership", user, self, True)
def remove_user(self, user):
"""
......@@ -367,6 +369,7 @@ class Group(Base):
if assoc is None:
raise AjaxException('user %s not in group %s' % (user.name, self.name), 409)
session.delete(assoc)
fire_callback("user.group.membership", user, self, False)
def is_member(self, user):
"""
......
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