Esempio n. 1
0
    def submit(self):

        FormControllerMixin.submit(self)
        publishable = self.context["publishable"]

        # Adding roles
        instance = self.form_instance
        instance.roles.extend(publishable.roles)

        # If require email confirmation, disabled authenticated access
        # and send email confirmation message
        confirmation_email_template = publishable.confirmation_email_template
        if confirmation_email_template:
            instance.enabled = False
            instance.confirmed_email = False
            confirmation_email_template.send(self.email_parameters)
            # Storing instance
            instance.insert()
            datastore.commit()
        else:
            # Storing instance
            instance.insert()
            datastore.commit()
            # Getting confirmation target uri
            confirmation_target = self.context[
                "publishable"].confirmation_target
            uri = self.context["cms"].uri(confirmation_target)
            # Enabling user and autologin
            instance.enabled = True
            self.context["cms"].authentication.set_user_session(instance)
            # Redirecting to confirmation target
            raise cherrypy.HTTPRedirect(uri)
    def submit(self): 
        FormControllerMixin.submit(self)
        
        export_events = []
        tracker = StatusTracker()

        @when(tracker.file_processed)
        def handle_file_processed(event):
            if event.status == "failed":
                event.error_handled = True
            export_events.append(event)

        form = self.form_data

        user = get_current_user()
        user.require_permission(
            ExportationPermission,
            destination = form["destination"]
        )
        
        destination = form["destination"]
        snapshoter = form["snapshoter"]

        context = self.form_data.copy()

        exporter_context = destination.export(
            snapshoter,
            self.selection,
            update_only = form["update_only"],
            status_tracker = tracker,
            context = context
        )

        # View class
        self.view_class = destination.view_class(exporter_context)
        
        self.output["export_events"] = export_events
        self.output.update(
            **destination.output(exporter_context)
        )

        datastore.commit()