Esempio n. 1
0
    def __call__(self, *args, **kwargs):
        """Handle subscription request.

        If the context is an Open Section, approve immediately.

        If the context is a Closed Section, send approval and redirect to
        "My Subscriptions" (where the request will show).
        """
        user_id = self.context.portal_membership.getAuthenticatedMember().id
        if IOpenSection.providedBy(self.context):
            message = self.manager.immediatelySubscribeMember(user_id)
            addStatus(self.request, message)
            self.request.RESPONSE.redirect(self.context.absolute_url())
        else:
            if IClosedSection.providedBy(self.context):
                message = self.manager.addRequest(user_id)
                addStatus(self.request, message)
                redirect_url = self.context.portal_url(
                ) + '/@@my-subscriptions'
                self.request.RESPONSE.redirect(redirect_url)
            else:
                message = """The folder is marked as a Subscribable
Section, but doesn't seem to be of the type Closed Section 
or Open Section."""
                raise Exception(message)
Esempio n. 2
0
 def processForm(self):
     form = self.request.form
     table_data = self.table_data()
     # check for submitted form: button name should match the one in table
     # data
     button_names = [ table_data[key]['button_name'] for key in \
                                                             table_data.keys() ]
     if len(set(form.keys()) & set(button_names)) > 0:
         # process requests
         if form.has_key(table_data['requests']['button_name']):
             # approve subscription requests
             for user_id in form.get('users.id.approve', []):
                 message = self.manager.confirmSubscription(user_id)
                 addStatus(self.request, message)
             # remove subscription requests
             for user_id in form.get('users.id.remove', []):
                 message = self.manager.removeRequest(user_id)
                 addStatus(self.request, message)
         if form.has_key(table_data['subscriptions']['button_name']):
             # remove subscriptions
             for user_id in form.get('users.id.remove', []):
                 message = self.manager.removeSubscription(user_id)
                 addStatus(self.request, message)
         # redirect in order to show status message
         self.request.RESPONSE.redirect(self.request.URL)
     else:
         # no form submitted, do nothing
         pass
 def processForm(self):
     form = self.request.form
     table_data = self.table_data()
     # check for submitted form: button name should match the one in table 
     # data
     button_names = [ table_data[key]['button_name'] for key in \
                                                             table_data.keys() ]
     if len(set(form.keys()) & set(button_names)) > 0:
         # process requests
         if form.has_key(table_data['requests']['button_name']):
             # approve subscription requests
             for user_id in form.get('users.id.approve', []):
                 message = self.manager.confirmSubscription(user_id)
                 addStatus(self.request, message)
             # remove subscription requests
             for user_id in form.get('users.id.remove', []):
                 message = self.manager.removeRequest(user_id)
                 addStatus(self.request, message)
         if form.has_key(table_data['subscriptions']['button_name']):
             # remove subscriptions
             for user_id in form.get('users.id.remove', []):
                 message = self.manager.removeSubscription(user_id)
                 addStatus(self.request, message)
         # redirect in order to show status message
         self.request.RESPONSE.redirect(self.request.URL)
     else:
         # no form submitted, do nothing
         pass
    def __call__(self, *args, **kwargs):
        """Handle subscription request.

        If the context is an Open Section, approve immediately.

        If the context is a Closed Section, send approval and redirect to
        "My Subscriptions" (where the request will show).
        """
        user_id = self.context.portal_membership.getAuthenticatedMember().id
        if IOpenSection.providedBy(self.context):
            message = self.manager.immediatelySubscribeMember(user_id)
            addStatus(self.request, message)        
            self.request.RESPONSE.redirect(self.context.absolute_url())
        else:
            if IClosedSection.providedBy(self.context):
                message = self.manager.addRequest(user_id)
                addStatus(self.request, message)
                redirect_url = self.context.portal_url() + '/@@my-subscriptions'
                self.request.RESPONSE.redirect(redirect_url)
            else:
                message = """The folder is marked as a Subscribable
Section, but doesn't seem to be of the type Closed Section 
or Open Section."""
                raise Exception(message)