force import of AuthorizeHelpers
[plcapi.git] / PLC / Methods / UpdatePersonTag.py
index 176b22e..da443ee 100644 (file)
@@ -9,6 +9,7 @@ from PLC.Auth import Auth
 from PLC.PersonTags import PersonTag, PersonTags
 from PLC.Persons import Person, Persons
 
+# need to import so the core classes get decorated with caller_may_write_tag
 from PLC.AuthorizeHelpers import AuthorizeHelpers
 
 class UpdatePersonTag(Method):
@@ -42,13 +43,7 @@ class UpdatePersonTag(Method):
         person=persons[0]
 
         # check authorizations
-        if 'admin' in self.caller['roles']:
-            pass
-        # user can change tags on self
-        elif AuthorizeHelpers.person_may_access_person (self.api, self.caller, person):
-            pass
-        else:
-            raise PLCPermissionDenied, "%s: you can only change your own tags"%self.name
+        person.caller_may_write_tag(self.api,self.caller,tag_type)
 
         person_tag['value'] = value
         person_tag.sync()