change_avatar = InterfaceCallProperty has_avatar = InterfaceWriteProperty class SetManagePermissions: pass UserInterfaces = { 'Viewer':UserViewer, 'SetManagePermissions':SetManagePermissions, 'Editor':UserEditor, } add_type_to_interface_map(User, UserInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db SliderOptions = {'InterfaceOrder':[], 'InterfaceLabels':{}} SetSliderOptions(User, SliderOptions) # if the security context is in this agent, this set of slider_agents apply, irrespective of the type of resource they are def get_slider_agents(scontext) : return [ ('anonymous_group', get_anonymous_group().get_ref()), ('all_members_group', get_all_members_group().get_ref()), ('context_agent', scontext.context_agent),
is_site_invitation = InterfaceCallProperty make_accept_user = InterfaceCallProperty class MemberInviteEditor(): pk = InterfaceReadWriteProperty invited = InterfaceReadWriteProperty invited_by = InterfaceReadWriteProperty group = InterfaceReadWriteProperty message = InterfaceReadWriteProperty status = InterfaceReadWriteProperty date = InterfaceReadWriteProperty is_site_invitation = InterfaceCallProperty class MemberInviteAccept(): pk = InterfaceReadProperty accept = InterfaceCallProperty make_accept_url = InterfaceCallProperty status = InterfaceReadWriteProperty accepted_by = InterfaceReadWriteProperty delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map MemberInviteInterfaces = {'Viewer': MemberInviteViewer, 'Editor': MemberInviteEditor, 'Accept': MemberInviteAccept} add_type_to_interface_map(MemberInvite, MemberInviteInterfaces) SliderOptions = {'InterfaceOrder': ['Viewer', 'Editor', 'Accept']} SetSliderOptions(MemberInvite, SliderOptions) child_types = [] SetPossibleTypes(MemberInvite, child_types)
author = InterfaceWriteProperty class WikiPageCreator: created_by = InterfaceWriteProperty class WikiPageManager: delete = InterfaceCallProperty move_to_new_group = InterfaceCallProperty class WikiPageCommentor: comment = InterfaceCallProperty class WikiPageCommentViewer: view_comments = InterfaceReadProperty if not get_interface_map(WikiPage): WikiPageInterfaces = {'Viewer':WikiPageViewer, 'Editor':WikiPageEditor, 'Manager':WikiPageManager, 'Creator':WikiPageCreator, "Commentor":WikiPageCommentor, "ViewComments":WikiPageCommentViewer} add_type_to_interface_map(content_type, WikiPageInterfaces) if not SliderOptions.get(WikiPage, False): SetSliderOptions(WikiPage, {'InterfaceOrder':['Viewer', 'Editor','Commentor', 'Manager', 'ManagePermissions'], 'InterfaceLabels':{'Viewer':'View', 'Editor':'Edit', 'Commentor':'Comment', 'Manager':'Manage (Move / Delete)', 'ManagePermissions':'Change Permissions'}})
status = InterfaceReadWriteProperty accepted_by = InterfaceReadWriteProperty delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map ApplicationInterfaces = {'Viewer': ApplicationViewer, 'Editor': ApplicationEditor, 'Accept': ApplicationAccept } add_type_to_interface_map(Application, ApplicationInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db SliderOptions = {'InterfaceOrder':['Viewer', 'Editor', 'Accept']} SetSliderOptions(Application, SliderOptions) # ChildTypes are used to determine what types of objects can be created in this security context (and acquire security context from this). These are used when creating an explicit security context for an object of this type. child_types = [] SetPossibleTypes(Application, child_types)
delete = InterfaceCallProperty class ApplicationReject: pk = InterfaceReadProperty reject = InterfaceCallProperty delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map ApplicationInterfaces = { 'Viewer': ApplicationViewer, 'Editor': ApplicationEditor, 'Accept': ApplicationAccept, 'Reject': ApplicationReject, } add_type_to_interface_map(Application, ApplicationInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db SliderOptions = {'InterfaceOrder': ['Viewer', 'Editor', 'Accept', 'Reject']} SetSliderOptions(Application, SliderOptions) # ChildTypes are used to determine what types of objects can be created in this security context (and acquire security context from this). These are used when creating an explicit security context for an object of this type. child_types = [] SetPossibleTypes(Application, child_types)
pk = InterfaceReadWriteProperty invited = InterfaceReadWriteProperty invited_by = InterfaceReadWriteProperty group = InterfaceReadWriteProperty message = InterfaceReadWriteProperty status = InterfaceReadWriteProperty date = InterfaceReadWriteProperty is_site_invitation = InterfaceCallProperty class MemberInviteAccept(): pk = InterfaceReadProperty accept = InterfaceCallProperty make_accept_url = InterfaceCallProperty status = InterfaceReadWriteProperty accepted_by = InterfaceReadWriteProperty delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map MemberInviteInterfaces = { 'Viewer': MemberInviteViewer, 'Editor': MemberInviteEditor, 'Accept': MemberInviteAccept } add_type_to_interface_map(MemberInvite, MemberInviteInterfaces) SliderOptions = {'InterfaceOrder': ['Viewer', 'Editor', 'Accept']} SetSliderOptions(MemberInvite, SliderOptions) child_types = [] SetPossibleTypes(MemberInvite, child_types)
from apps.plus_feed.models import FeedItem from apps.plus_permissions.models import add_type_to_interface_map content_type = FeedItem child_types = [] class FeedItemViewer : id = InterfaceReadProperty short = InterfaceReadProperty expanded = InterfaceReadProperty external_link = InterfaceReadProperty type = InterfaceReadProperty target = InterfaceReadProperty source = InterfaceReadProperty sent = InterfaceReadProperty has_avatar = InterfaceCallProperty UserInterfaces = { 'Viewer' : FeedItemViewer, } add_type_to_interface_map(FeedItem, UserInterfaces) SliderOptions = {'InterfaceOrder':['Viewer'], 'InterfaceLabels':{'Viewer':'View'}} SetSliderOptions(FeedItem, SliderOptions)
class LinkEditor: text = InterfaceWriteProperty url = InterfaceWriteProperty target = InterfaceWriteProperty service = InterfaceWriteProperty class LinkDelete: delete = InterfaceCallProperty class LinkManager: delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map LinkInterfaces = { 'Viewer': LinkViewer, 'Editor': LinkEditor, 'Delete': LinkDelete, 'Manager': LinkManager } add_type_to_interface_map(Link, LinkInterfaces) SliderOptions = {'InterfaceOrder': ['Viewer', 'Manager']} SetSliderOptions(Link, SliderOptions) child_types = [] SetPossibleTypes(Link, child_types)
project_stage = InterfaceReadProperty assistance_offered = InterfaceReadProperty class HostInfoEditor: find_out = InterfaceWriteProperty peer_mentoring = InterfaceWriteProperty expected_membership_benefits = InterfaceWriteProperty project = InterfaceWriteProperty project_stage = InterfaceWriteProperty assistance_offered = InterfaceWriteProperty from apps.plus_permissions.models import add_type_to_interface_map HostInfoInterfaces = { 'Viewer': HostInfoViewer, 'Editor': HostInfoEditor, } add_type_to_interface_map(HostInfo, HostInfoInterfaces) SliderOptions = { 'InterfaceOrder': ['Viewer'], 'InterfaceLabels': { 'Viewer': 'View', 'Editor': 'Edit' } } SetSliderOptions(HostInfo, SliderOptions)
from apps.plus_permissions.models import add_type_to_interface_map ProfileInterfaces = {'Viewer': ProfileViewer, 'Editor': ProfileEditor, 'EmailAddressViewer' : ProfileEmailAddressViewer, 'HomeViewer' : ProfileHomeViewer, 'WorkViewer' : ProfileWorkViewer, 'MobileViewer' : ProfileMobileViewer, 'FaxViewer' : ProfileFaxViewer, 'AddressViewer' : ProfileAddressViewer, 'SkypeViewer' : ProfileSkypeViewer, 'SipViewer' : ProfileSipViewer} add_type_to_interface_map(Profile, ProfileInterfaces) SliderOptions = {'InterfaceOrder':['Viewer'], 'InterfaceLabels':{'Viewer':'View', 'Editor':'Edit'}} SetSliderOptions(Profile, SliderOptions) """ Data for User.py slide = interfaces['Viewer'].make_slider_for(resource,options,owner,0,creator) slide = interfaces['Editor'].make_slider_for(resource,options,owner,2,creator) slide = interfaces['EmailAddressViewer'].make_slider_for(resource,options,owner,1,creator) slide = interfaces['HomeViewer'].make_slider_for(resource,options,owner,2,creator) slide = interfaces['WorkViewer'].make_slider_for(resource,options,owner,2,creator) slide = interfaces['MobileViewer'].make_slider_for(resource,options,owner,2,creator) slide = interfaces['FaxViewer'].make_slider_for(resource,options,owner,2,creator)
TgGroupInterfaces = { 'Viewer': TgGroupViewer, 'Editor': TgGroupEditor, 'Delete': TgGroupDelete, 'ManageMembers': TgGroupManageMembers, 'Join': TgGroupJoin, 'Leave': TgGroupLeave, 'Commentor': TgGroupComment, 'Uploader': TgGroupUploader, 'Message': TgGroupMessage, 'Invite': TgGroupInvite, 'GroupTypeEditor': TgGroupTypeEditor, 'StatusViewer': TgGroupStatusViewer, 'SetManagePermissions': SetManagePermissions } add_type_to_interface_map(TgGroup, TgGroupInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db if not SliderOptions.get(TgGroup, False): SetSliderOptions( TgGroup, { 'InterfaceOrder': [ 'Viewer', 'Editor', 'Join', 'Uploader', 'Commentor', 'Invite', 'Message', 'ManageMembers', 'Delete', 'ManagePermissions' ], 'InterfaceLabels': { 'Viewer': 'View', 'Editor': 'Edit', 'Commentor': 'Comment',
# Here's the wrapping we have to put around it. class OurPostViewer: title = InterfaceReadProperty body = InterfaceReadProperty class OurPostEditor: title = InterfaceWriteProperty body = InterfaceWriteProperty delete = InterfaceCallProperty class OurPostCommentor: pass from apps.plus_permissions.models import add_type_to_interface_map, get_interface_map OurPostInterfaces = { 'Viewer': OurPostViewer, 'Editor': OurPostEditor, 'Commentor': OurPostCommentor } add_type_to_interface_map(content_type, OurPostInterfaces) SliderOptions = {'InterfaceOrder': ['Viewer', 'Editor', 'Commentor']} SetSliderOptions(content_type, SliderOptions)
class SetManagePermissions: pass from apps.plus_permissions.models import add_type_to_interface_map if not get_interface_map(TgGroup): TgGroupInterfaces = {'Viewer': TgGroupViewer, 'Editor': TgGroupEditor, 'Invite': TgGroupInviteMember, 'ManageMembers': TgGroupManageMembers, 'Join': TgGroupJoin, 'Comment':TgGroupComment, 'Uploader':TgGroupUploader, 'SetManagePermissions':SetManagePermissions} add_type_to_interface_map(TgGroup, TgGroupInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db if not SliderOptions.get(TgGroup, False): SetSliderOptions(TgGroup, {'InterfaceOrder':['Viewer', 'Editor', 'Invite', 'Join', 'Uploader', 'ManageMembers', 'ManagePermissions'], 'InterfaceLabels':{'Viewer':'View', 'Editor': 'Edit', 'ManageMembers': 'Manage Membership', 'ManagePermissions':'Change Permissions'}}) # ChildTypes are used to determine what types of objects can be created in this security context (and acquire security context from this). These are used when creating an explicit security context for an object of this type. if TgGroup not in PossibleTypes:
# Here we set separate interfaces for creating virtual groups and real world hubs / regions . Different permissions for each class SiteCreateVirtual: create_virtual = InterfaceCallProperty create_TgGroup = InterfaceCallProperty class SiteCreateHub: create_hub = InterfaceCallProperty create_TgGroup = InterfaceCallProperty SiteInterfaces = { 'CreateVirtual' : SiteCreateVirtual, 'CreateHub' : SiteCreateHub, } add_type_to_interface_map(Site, SiteInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db SliderOptions = {'InterfaceOrder':['CreateVirtual','CreateHub']} SetSliderOptions(Site, SliderOptions) # ChildTypes are used to determine what types of objects can be created in this security context (and acquire security context from this). These are used when creating an explicit security context for an object of this type. child_types = [TgGroup, Application, Contact] SetPossibleTypes(Site, child_types)
SetTypeLabels, ) from apps.plus_feed.models import FeedItem from apps.plus_permissions.models import add_type_to_interface_map content_type = FeedItem child_types = [] class FeedItemViewer: id = InterfaceReadProperty short = InterfaceReadProperty expanded = InterfaceReadProperty external_link = InterfaceReadProperty type = InterfaceReadProperty target = InterfaceReadProperty source = InterfaceReadProperty sent = InterfaceReadProperty has_avatar = InterfaceCallProperty UserInterfaces = {"Viewer": FeedItemViewer} add_type_to_interface_map(FeedItem, UserInterfaces) SliderOptions = {"InterfaceOrder": ["Viewer"], "InterfaceLabels": {"Viewer": "View"}} SetSliderOptions(FeedItem, SliderOptions)
comment = InterfaceCallProperty class ResourceDelete: delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map ResourceInterfaces = { 'Viewer': ResourceViewer, 'Editor': ResourceEditor, 'Commentor': ResourceCommentor, 'Delete': ResourceDelete, 'Manager': ResourceManager, } add_type_to_interface_map(Resource, ResourceInterfaces) if not SliderOptions.get(Resource, False): SetSliderOptions( Resource, { 'InterfaceOrder': ['Viewer', 'Editor', 'Commentor', 'Manager'], 'InterfaceLabels': { 'Viewer': 'View', 'Editor': 'Edit', 'Commentor': 'Comment', 'Manager': 'Manage (Move / Delete)', 'ManagePermissions': 'Change Permissions' } }) child_types = []
stub = InterfaceWriteProperty class WikiPageCreator: created_by = InterfaceWriteProperty class WikiPageDelete: delete = InterfaceCallProperty class WikiPageCommentor: comment = InterfaceCallProperty class WikiPageCommentReader: view_comments = InterfaceReadProperty if not get_interface_map(WikiPage): WikiPageInterfaces = {'Viewer':WikiPageViewer, 'Editor':WikiPageEditor, 'Delete':WikiPageDelete, 'Creator':WikiPageCreator, "Commentor":WikiPageCommentor, "ViewComments":WikiPageCommentReader} add_type_to_interface_map(content_type, WikiPageInterfaces) if not SliderOptions.get(WikiPage, False): SetSliderOptions(WikiPage, {'InterfaceOrder':['Viewer', 'Editor','Commentor', 'ManagePermissions'], 'InterfaceLabels':{'Viewer':'View', 'Editor':'Edit', 'Commentor':'Comment', 'ManagePermissions':'Change Permissions'}})
find_out = InterfaceReadProperty peer_mentoring = InterfaceReadProperty expected_membership_benefits = InterfaceReadProperty project = InterfaceReadProperty project_stage = InterfaceReadProperty assistance_offered = InterfaceReadProperty class HostInfoEditor : find_out = InterfaceWriteProperty peer_mentoring = InterfaceWriteProperty expected_membership_benefits = InterfaceWriteProperty project = InterfaceWriteProperty project_stage = InterfaceWriteProperty assistance_offered = InterfaceWriteProperty from apps.plus_permissions.models import add_type_to_interface_map HostInfoInterfaces = {'Viewer': HostInfoViewer, 'Editor': HostInfoEditor, } add_type_to_interface_map(HostInfo, HostInfoInterfaces) SliderOptions = {'InterfaceOrder':['Viewer'], 'InterfaceLabels':{'Viewer':'View', 'Editor':'Edit'}} SetSliderOptions(HostInfo, SliderOptions)
change_avatar = InterfaceCallProperty has_avatar = InterfaceWriteProperty class SetManagePermissions: pass UserInterfaces = { 'Viewer': UserViewer, 'SetManagePermissions': SetManagePermissions, 'Editor': UserEditor, } add_type_to_interface_map(User, UserInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db SliderOptions = {'InterfaceOrder': [], 'InterfaceLabels': {}} SetSliderOptions(User, SliderOptions) # if the security context is in this agent, this set of slider_agents apply, irrespective of the type of resource they are def get_slider_agents(scontext): return [('anonymous_group', get_anonymous_group().get_ref()), ('all_members_group', get_all_members_group().get_ref()), ('context_agent', scontext.context_agent), ('context_admin', scontext.context_admin)]
from apps.plus_permissions.models import SetSliderOptions, SetAgentDefaults, SetPossibleTypes, \ SetSliderAgents, SetVisibleAgents, SetVisibleTypes, PossibleTypes, SetTypeLabels from apps.plus_permissions.models import add_type_to_interface_map from apps.plus_feed.models import AggregateFeed content_type = AggregateFeed child_types = [] class AggregateFeedViewer: target = InterfaceReadProperty UserInterfaces = { 'Viewer': AggregateFeedViewer, } add_type_to_interface_map(AggregateFeed, UserInterfaces) SliderOptions = { 'InterfaceOrder': ['Viewer'], 'InterfaceLabels': { 'Viewer': 'View' } } SetSliderOptions(AggregateFeed, SliderOptions)
stub = InterfaceReadProperty name = InterfaceReadProperty in_agent = InterfaceReadProperty class ResourceEditor : title = InterfaceWriteProperty description = InterfaceWriteProperty author = InterfaceWriteProperty license = InterfaceWriteProperty resource = InterfaceWriteProperty class ResourceManager : delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map ResourceInterfaces = { 'Viewer': ResourceViewer, 'Editor': ResourceEditor, 'Manager' : ResourceManager } add_type_to_interface_map(Resource, ResourceInterfaces) if not SliderOptions.get(Resource, False): SetSliderOptions(Resource, {'InterfaceOrder':['Viewer', 'Editor', 'Manager'], 'InterfaceLabels':{}}) child_types = [] SetPossibleTypes(Resource, child_types) SetTypeLabels(content_type, 'Upload')
from apps.plus_permissions.interfaces import InterfaceReadProperty, InterfaceWriteProperty, InterfaceCallProperty, InterfaceReadWriteProperty from apps.plus_permissions.models import SetSliderOptions, SetAgentDefaults, SetPossibleTypes, SetSliderAgents from apps.plus_links.models import Link content_type = Link class LinkViewer : text = InterfaceReadProperty url = InterfaceReadProperty target = InterfaceReadProperty service = InterfaceReadProperty class LinkRemover : remove_link = InterfaceCallProperty class LinkManager : delete = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map LinkInterfaces = {'Viewer' : LinkViewer, 'Remover' : LinkRemover, 'Manager' : LinkManager } add_type_to_interface_map(Link, LinkInterfaces) SliderOptions = {'InterfaceOrder':['Viewer', 'Remover', 'Manager']} SetSliderOptions(Link, SliderOptions) child_types = [] SetPossibleTypes(Link, child_types)
cc_messages_to_email = InterfaceWriteProperty change_avatar = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map ProfileInterfaces = { 'Viewer': ProfileViewer, 'Editor': ProfileEditor, 'EmailAddressViewer': ProfileEmailAddressViewer, 'HomeViewer': ProfileHomeViewer, 'WorkViewer': ProfileWorkViewer, 'MobileViewer': ProfileMobileViewer, 'FaxViewer': ProfileFaxViewer, 'AddressViewer': ProfileAddressViewer, 'SkypeViewer': ProfileSkypeViewer, 'SipViewer': ProfileSipViewer } add_type_to_interface_map(Profile, ProfileInterfaces) SliderOptions = { 'InterfaceOrder': ['Viewer'], 'InterfaceLabels': { 'Viewer': 'View', 'Editor': 'Edit' } } SetSliderOptions(Profile, SliderOptions)
# Here's the wrapping we have to put around it. class OurPostViewer: title = InterfaceReadProperty body = InterfaceReadProperty class OurPostEditor: title = InterfaceWriteProperty body = InterfaceWriteProperty delete = InterfaceCallProperty class OurPostCommentor: pass from apps.plus_permissions.models import add_type_to_interface_map, get_interface_map OurPostInterfaces = {'Viewer':OurPostViewer, 'Editor':OurPostEditor, 'Commentor':OurPostCommentor} add_type_to_interface_map(content_type, OurPostInterfaces) SliderOptions = {'InterfaceOrder':['Viewer', 'Editor','Commentor']} SetSliderOptions(content_type, SliderOptions)
find_out = InterfaceReadWriteProperty invited_by = InterfaceReadWriteProperty become_member = InterfaceCallProperty invite = InterfaceCallProperty has_group_request = InterfaceCallProperty class ContactInvite: pk = InterfaceReadProperty invite = InterfaceCallProperty from apps.plus_permissions.models import add_type_to_interface_map ContactInterfaces = {'ContactAdmin': ContactAdmin, 'ContactInvite' : ContactInvite } add_type_to_interface_map(Contact, ContactInterfaces) # use InterfaceOrder to draw the slider and constraints, these are used in rendering the sliders and in validating the results # these exist on a per type basis and are globals for their type. # they don't need to be stored in the db SliderOptions = {'InterfaceOrder':['ContactAdmin']} SetSliderOptions(Contact, SliderOptions) # ChildTypes are used to determine what types of objects can be created in this security context (and acquire security context from this). These are used when creating an explicit security context for an object of this type. child_types = [] SetPossibleTypes(Contact, child_types)
SetSliderOptions, SetAgentDefaults, SetPossibleTypes, SetSliderAgents, SetVisibleAgents, SetVisibleTypes, PossibleTypes, SetTypeLabels, ) from apps.plus_permissions.models import add_type_to_interface_map from apps.plus_feed.models import AggregateFeed content_type = AggregateFeed child_types = [] class AggregateFeedViewer: target = InterfaceReadProperty UserInterfaces = {"Viewer": AggregateFeedViewer} add_type_to_interface_map(AggregateFeed, UserInterfaces) SliderOptions = {"InterfaceOrder": ["Viewer"], "InterfaceLabels": {"Viewer": "View"}} SetSliderOptions(AggregateFeed, SliderOptions)