# Copyright (c) 2015, InfluxFramework LLC
# License: MIT. See LICENSE

import influxframework
from influxframework.model.document import Document


class HasRole(Document):
	def before_insert(self):
		if influxframework.db.exists("Has Role", {"parent": self.parent, "role": self.role}):
			influxframework.throw(influxframework._("User '{0}' already has the role '{1}'").format(self.parent, self.role))
