src/pyams_content/shared/common/interfaces/__init__.py
changeset 1358 c682811fa1ea
parent 1319 e72aa60c1e4d
child 1366 3c6e0134064f
equal deleted inserted replaced
1357:329116e5f8e3 1358:c682811fa1ea
    36 
    36 
    37 class IBaseContentManagerRoles(Interface):
    37 class IBaseContentManagerRoles(Interface):
    38     """Shared tool roles interface"""
    38     """Shared tool roles interface"""
    39 
    39 
    40     webmasters = PrincipalsSet(title=_("Webmasters"),
    40     webmasters = PrincipalsSet(title=_("Webmasters"),
    41                                description=_("Webmasters can handle all contents, including published ones"),
    41                                description=_("Webmasters can handle all contents, including "
       
    42                                              "published ones"),
    42                                role_id=WEBMASTER_ROLE,
    43                                role_id=WEBMASTER_ROLE,
    43                                required=False)
    44                                required=False)
    44 
    45 
    45     pilots = PrincipalsSet(title=_("Pilots"),
    46     pilots = PrincipalsSet(title=_("Pilots"),
    46                            description=_("Pilots can handle tool configuration, manage access rules, grant users "
    47                            description=_("Pilots can handle tool configuration, manage access "
    47                                          "roles and manage managers restrictions"),
    48                                          "rules, grant users roles and manage managers "
       
    49                                          "restrictions"),
    48                            role_id=PILOT_ROLE,
    50                            role_id=PILOT_ROLE,
    49                            required=False)
    51                            required=False)
    50 
    52 
    51     managers = PrincipalsSet(title=_("Managers"),
    53     managers = PrincipalsSet(title=_("Managers"),
    52                              description=_("Managers can handle main operations in tool's workflow, like publish "
    54                              description=_("Managers can handle main operations in tool's "
    53                                            "or retire contents"),
    55                                            "workflow, like publish or retire contents"),
    54                              role_id=MANAGER_ROLE,
    56                              role_id=MANAGER_ROLE,
    55                              required=False)
    57                              required=False)
    56 
    58 
    57     contributors = PrincipalsSet(title=_("Contributors"),
    59     contributors = PrincipalsSet(title=_("Contributors"),
    58                                  description=_("Contributors are users which are allowed to create new contents"),
    60                                  description=_("Contributors are users which are allowed to "
       
    61                                                "create new contents"),
    59                                  role_id=CONTRIBUTOR_ROLE,
    62                                  role_id=CONTRIBUTOR_ROLE,
    60                                  required=False)
    63                                  required=False)
    61 
    64 
    62     designers = PrincipalsSet(title=_("Designers"),
    65     designers = PrincipalsSet(title=_("Designers"),
    63                               description=_("Designers are users which are allowed to manage presentation templates"),
    66                               description=_("Designers are users which are allowed to manage "
       
    67                                             "presentation templates"),
    64                               role_id=DESIGNER_ROLE,
    68                               role_id=DESIGNER_ROLE,
    65                               required=False)
    69                               required=False)
    66 
    70 
    67 
    71 
    68 class ISharedSite(IBaseContent, IDeletableElement):
    72 class ISharedSite(IBaseContent, IDeletableElement):
    81 class IBaseSharedTool(IBaseContent, IContainer):
    85 class IBaseSharedTool(IBaseContent, IContainer):
    82     """Base shared tool interface"""
    86     """Base shared tool interface"""
    83 
    87 
    84     containers(ISharedToolContainer)
    88     containers(ISharedToolContainer)
    85 
    89 
    86     shared_content_menu = Attribute("Boolean flag indicating if tool is displayed into 'Shared contents' or "
    90     shared_content_menu = Attribute("Boolean flag indicating if tool is displayed into 'Shared "
    87                                     "Shared tools' menu")
    91                                     "contents' or Shared tools' menu")
    88 
    92 
    89     shared_content_workflow = Choice(title=_("Workflow name"),
    93     shared_content_workflow = Choice(title=_("Workflow name"),
    90                                      description=_("Name of workflow utility used to manage tool contents"),
    94                                      description=_("Name of workflow utility used to manage tool "
       
    95                                                    "contents"),
    91                                      vocabulary="PyAMS workflows",
    96                                      vocabulary="PyAMS workflows",
    92                                      default="PyAMS default workflow")
    97                                      default="PyAMS default workflow")
    93 
    98 
    94 
    99 
    95 SHARED_TOOL_WORKFLOW_STATES_VOCABULARY = 'PyAMS workflow states'
   100 SHARED_TOOL_WORKFLOW_STATES_VOCABULARY = 'PyAMS workflow states'
   117 
   122 
   118     content_type = Attribute("Content data type")
   123     content_type = Attribute("Content data type")
   119     content_name = Attribute("Content name")
   124     content_name = Attribute("Content name")
   120 
   125 
   121     content_url = TextLine(title=_("Content URL"),
   126     content_url = TextLine(title=_("Content URL"),
   122                            description=_("URL used to access this content; this is important for SEO and "
   127                            description=_("URL used to access this content; this is important for "
   123                                          "should include most important words describing content; spaces and "
   128                                          "SEO and should include most important words describing "
   124                                          "underscores will be automatically replaced by hyphens"),
   129                                          "content; spaces and underscores will be automatically "
       
   130                                          "replaced by hyphens"),
   125                            required=True)
   131                            required=True)
   126 
   132 
   127     handle_content_url = Attribute("Static boolean value to specify if content URL is supported by this content type")
   133     handle_content_url = Attribute("Static boolean value to specify if content URL is supported by "
       
   134                                    "this content type")
   128 
   135 
   129     creator = Principal(title=_("Version creator"),
   136     creator = Principal(title=_("Version creator"),
   130                         description=_("Name of content's version creator. "
   137                         description=_("Name of content's version creator. "
   131                                       "The creator of the first version is also it's owner."),
   138                                       "The creator of the first version is also it's owner."),
   132                         required=True)
   139                         required=True)
   152 
   159 
   153     header = I18nTextField(title=_("Header"),
   160     header = I18nTextField(title=_("Header"),
   154                            description=_("Content's header is generally displayed in page header"),
   161                            description=_("Content's header is generally displayed in page header"),
   155                            required=False)
   162                            required=False)
   156 
   163 
   157     handle_header = Attribute("Static boolean value to specify if header is supported by this content type")
   164     handle_header = Attribute("Static boolean value to specify if header is supported by this "
       
   165                               "content type")
   158 
   166 
   159     description = I18nTextField(title=_("Meta-description"),
   167     description = I18nTextField(title=_("Meta-description"),
   160                                 description=_("The content's description is 'hidden' into HTML's page headers; but it "
   168                                 description=_("The content's description is 'hidden' into HTML's "
   161                                               "can be seen, for example, in some search engines results as content's "
   169                                               "page headers; but it can be seen, for example, in "
   162                                               "description; if description is empty, content's header will be used."),
   170                                               "some search engines results as content's "
       
   171                                               "description; if description is empty, content's "
       
   172                                               "header will be used."),
   163                                 required=False)
   173                                 required=False)
   164 
   174 
   165     handle_description = Attribute("Static boolean value to specify if description is supported by this content type")
   175     handle_description = Attribute("Static boolean value to specify if description is supported by "
       
   176                                    "this content type")
   166 
   177 
   167     keywords = TextLineListField(title=_("Keywords"),
   178     keywords = TextLineListField(title=_("Keywords"),
   168                                  description=_("They will be included into HTML pages metadata"),
   179                                  description=_("They will be included into HTML pages metadata"),
   169                                  required=False)
   180                                  required=False)
   170 
   181 
   187 
   198 
   188 class IWfSharedContentRoles(Interface):
   199 class IWfSharedContentRoles(Interface):
   189     """Shared content roles"""
   200     """Shared content roles"""
   190 
   201 
   191     owner = PrincipalsSet(title=_("Content owner"),
   202     owner = PrincipalsSet(title=_("Content owner"),
   192                           description=_("The owner is the creator of content's first version, except if it was "
   203                           description=_("The owner is the creator of content's first version, "
   193                                         "transferred afterwards to another owner"),
   204                                         "except if it was transferred afterwards to another owner"),
   194                           role_id=OWNER_ROLE,
   205                           role_id=OWNER_ROLE,
   195                           required=True,
   206                           required=True,
   196                           max_length=1)
   207                           max_length=1)
   197 
   208 
   198     managers = PrincipalsSet(title=_("Managers"),
   209     managers = PrincipalsSet(title=_("Managers"),
   199                              description=_("Managers can handle main operations in tool's workflow, like publish "
   210                              description=_("Managers can handle main operations in tool's "
   200                                            "or retire contents"),
   211                                            "workflow, like publish or retire contents"),
   201                              role_id=MANAGER_ROLE,
   212                              role_id=MANAGER_ROLE,
   202                              required=False)
   213                              required=False)
   203 
   214 
   204     contributors = PrincipalsSet(title=_("Contributors"),
   215     contributors = PrincipalsSet(title=_("Contributors"),
   205                                  description=_("Contributors are users which are allowed to update this content in "
   216                                  description=_("Contributors are users which are allowed to update "
   206                                                "addition to it's owner"),
   217                                                "this content in addition to it's owner"),
   207                                  role_id=CONTRIBUTOR_ROLE,
   218                                  role_id=CONTRIBUTOR_ROLE,
   208                                  required=False)
   219                                  required=False)
   209 
   220 
   210     designers = PrincipalsSet(title=_("Designers"),
   221     designers = PrincipalsSet(title=_("Designers"),
   211                               description=_("Designers are users which are allowed to manage presentation templates"),
   222                               description=_("Designers are users which are allowed to manage "
       
   223                                             "presentation templates"),
   212                               role_id=DESIGNER_ROLE,
   224                               role_id=DESIGNER_ROLE,
   213                               required=False)
   225                               required=False)
   214 
   226 
   215     readers = PrincipalsSet(title=_("Readers"),
   227     readers = PrincipalsSet(title=_("Readers"),
   216                             description=_("Readers are users which are asked to verify and comment contents before "
   228                             description=_("Readers are users which are asked to verify and comment "
   217                                           "they are published"),
   229                                           "contents before they are published"),
   218                             role_id=READER_ROLE,
   230                             role_id=READER_ROLE,
   219                             required=False)
   231                             required=False)
   220 
   232 
   221     guests = PrincipalsSet(title=_("Guests"),
   233     guests = PrincipalsSet(title=_("Guests"),
   222                            description=_("Guests are users which are allowed to view contents with restricted access"),
   234                            description=_("Guests are users which are allowed to view contents "
       
   235                                          "with restricted access"),
   223                            role_id=GUEST_ROLE,
   236                            role_id=GUEST_ROLE,
   224                            required=False)
   237                            required=False)
   225 
   238 
   226 
   239 
   227 class ISharedContent(IWorkflowManagedContent):
   240 class ISharedContent(IWorkflowManagedContent):
   284 
   297 
   285 class IContributorRestrictionInfo(IRestrictionInfo):
   298 class IContributorRestrictionInfo(IRestrictionInfo):
   286     """Shared content contributor restrictions"""
   299     """Shared content contributor restrictions"""
   287 
   300 
   288     publication_checks = Bool(title=_("Publication checks"),
   301     publication_checks = Bool(title=_("Publication checks"),
   289                               description=_("If 'yes', this contributor will have to confirm that contents have "
   302                               description=_("If 'yes', this contributor will have to confirm that "
   290                                             "been previewed and checked before asking for publication"),
   303                                             "contents have been previewed and checked before "
       
   304                                             "asking for publication"),
   291                               required=False,
   305                               required=False,
   292                               default=True)
   306                               default=True)
   293 
   307 
       
   308     owners = PrincipalsSet(title=_("Substitute for"),
       
   309                            description=_("Contributor will have access to contents owned by these "
       
   310                                          "principals"))
       
   311 
       
   312     def check_access(self, context, permission=MANAGE_CONTENT_PERMISSION, request=None):
       
   313         """Check if principal is granted access to given context"""
       
   314 
   294 
   315 
   295 class IContributorRestrictions(IRestrictions):
   316 class IContributorRestrictions(IRestrictions):
   296     """Contributor restrictions interface"""
   317     """Contributor restrictions interface"""
   297 
   318 
   298 
   319 
   309 
   330 
   310 class IManagerRestrictionInfo(IRestrictionInfo):
   331 class IManagerRestrictionInfo(IRestrictionInfo):
   311     """Shared content manager restrictions"""
   332     """Shared content manager restrictions"""
   312 
   333 
   313     publication_checks = Bool(title=_("Publication checks"),
   334     publication_checks = Bool(title=_("Publication checks"),
   314                               description=_("If 'yes', this manager will have to confirm that contents have "
   335                               description=_("If 'yes', this manager will have to confirm that "
   315                                             "been previewed and checked before publishing a content"),
   336                                             "contents have been previewed and checked before "
       
   337                                             "publishing a content"),
   316                               required=False,
   338                               required=False,
   317                               default=True)
   339                               default=True)
   318 
   340 
   319     restricted_contents = Bool(title=_("Restricted contents"),
   341     restricted_contents = Bool(title=_("Restricted contents"),
   320                                description=_("If 'yes', this manager will get restricted access to manage contents "
   342                                description=_("If 'yes', this manager will get restricted access "
   321                                              "based on selected settings"),
   343                                              "to manage contents based on selected settings"),
   322                                required=False,
   344                                required=False,
   323                                default=True)
   345                                default=True)
   324 
   346 
   325     owners = PrincipalsSet(title=_("Selected owners"),
   347     owners = PrincipalsSet(title=_("Selected owners"),
   326                            description=_("Manager will have access to contents owned by these principals"),
   348                            description=_("Manager will have access to contents owned by these "
       
   349                                          "principals"),
   327                            required=False)
   350                            required=False)
   328 
   351 
   329     def check_access(self, context, permission=MANAGE_CONTENT_PERMISSION, request=None):
   352     def check_access(self, context, permission=MANAGE_CONTENT_PERMISSION, request=None):
   330         """Check if principal is granted access to given content"""
   353         """Check if principal is granted access to given content"""
   331 
   354