from PLC.TagTypes import TagType, TagTypes
from PLC.SiteTags import SiteTag, SiteTags
+# need to import so the core classes get decorated with caller_may_write_tag
from PLC.AuthorizeHelpers import AuthorizeHelpers
class AddSiteTag(Method):
tag_type['tag_type_id'])
# check authorizations
- if 'admin' in self.caller['roles']:
- pass
- elif not AuthorizeHelpers.caller_may_access_tag_type (self.api, self.caller, tag_type):
- raise PLCPermissionDenied, "%s, forbidden tag %s"%(self.name,tag_type['tagname'])
- elif AuthorizeHelpers.person_belongs_to_site (self.api, self.caller, site):
- pass
- else:
- raise PLCPermissionDenied, "%s: you must be part of the subject site"%self.name
+ site.caller_may_write_tag(self.api,self.caller,tag_type)
site_tag = SiteTag(self.api)
site_tag['site_id'] = site['site_id']