better parsing of PLC_VSYS_DEFAULTS
[plcapi.git] / PLC / Methods / AddPersonTag.py
index edd3970..244b546 100644 (file)
@@ -10,6 +10,7 @@ from PLC.Persons import Person, Persons
 from PLC.TagTypes import TagType, TagTypes
 from PLC.PersonTags import PersonTag, PersonTags
 
+# need to import so the core classes get decorated with caller_may_write_tag
 from PLC.AuthorizeHelpers import AuthorizeHelpers
 
 class AddPersonTag(Method):
@@ -56,14 +57,7 @@ class AddPersonTag(Method):
                 (person['person_id'],person['email'], tag_type['tag_type_id'])
 
         # 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 = PersonTag(self.api)
         person_tag['person_id'] = person['person_id']