コード例 #1
0
ファイル: upload.py プロジェクト: anitahitouch/mediadrop
   def tsubmit(self, **kwargs):
       """
       """
       tlocalfile = tfile[kwargs['environ']['HTTP_COOKIE']]
       notify_to_author = True 
       if not kwargs['email'] :
           notify_to_author = False
           kwargs['email'] = "*****@*****.**"
 
       # Save the media_obj!
       media_obj = self.save_media_obj(
           kwargs['name'], kwargs['email'],
           kwargs['title'], kwargs['description'],
           None, tlocalfile, kwargs['url'],
       )
       """
       FIXED: creation notification email will now go to the authurs email
           also
       """
       #if notify_to_author:
       #    email.send_media_notification_to_author(media_obj)
       email.send_media_notification(media_obj)
       
       #delete the key
       del tfile[kwargs['environ']['HTTP_COOKIE']]
       #redirect to success page
       redirect(action='success')
コード例 #2
0
    def submit_async(self, **kwargs):
        """Ajax form validation and/or submission.

        This is the save handler for :class:`~mediadrop.forms.media.UploadForm`.

        When ajax is enabled this action is called for each field as the user
        fills them in. Although the entire form is validated, the JS only
        provides the value of one field at a time,

        :param validate: A JSON list of field names to check for validation
        :parma \*\*kwargs: One or more form field values.
        :rtype: JSON dict
        :returns:
            :When validating one or more fields:

            valid
                bool
            err
                A dict of error messages keyed by the field names

            :When saving an upload:

            success
                bool
            redirect
                If valid, the redirect url for the upload successful page.

        """
        if "validate" in kwargs:
            # we're just validating the fields. no need to worry.
            fields = json.loads(kwargs["validate"])
            err = {}
            for field in fields:
                if field in tmpl_context.form_errors:
                    err[field] = tmpl_context.form_errors[field]

            data = dict(valid=len(err) == 0, err=err)
        else:
            # We're actually supposed to save the fields. Let's do it.
            if len(tmpl_context.form_errors) != 0:
                # if the form wasn't valid, return failure
                tmpl_context.form_errors["success"] = False
                data = tmpl_context.form_errors
            else:
                # else actually save it!
                kwargs.setdefault("name")

                media_obj = self.save_media_obj(
                    kwargs["name"],
                    kwargs["email"],
                    kwargs["title"],
                    kwargs["description"],
                    None,
                    kwargs["file"],
                    kwargs["url"],
                )
                email.send_media_notification(media_obj)
                data = dict(success=True, redirect=url_for(action="success"))

        return data
コード例 #3
0
ファイル: upload.py プロジェクト: ruebenramirez/mediadrop
    def submit_async(self, **kwargs):
        """Ajax form validation and/or submission.

        This is the save handler for :class:`~mediadrop.forms.media.UploadForm`.

        When ajax is enabled this action is called for each field as the user
        fills them in. Although the entire form is validated, the JS only
        provides the value of one field at a time,

        :param validate: A JSON list of field names to check for validation
        :parma \*\*kwargs: One or more form field values.
        :rtype: JSON dict
        :returns:
            :When validating one or more fields:

            valid
                bool
            err
                A dict of error messages keyed by the field names

            :When saving an upload:

            success
                bool
            redirect
                If valid, the redirect url for the upload successful page.

        """
        if 'validate' in kwargs:
            # we're just validating the fields. no need to worry.
            fields = json.loads(kwargs['validate'])
            err = {}
            for field in fields:
                if field in tmpl_context.form_errors:
                    err[field] = tmpl_context.form_errors[field]

            data = dict(valid=len(err) == 0, err=err)
        else:
            # We're actually supposed to save the fields. Let's do it.
            if len(tmpl_context.form_errors) != 0:
                # if the form wasn't valid, return failure
                tmpl_context.form_errors['success'] = False
                data = tmpl_context.form_errors
            else:
                # else actually save it!
                kwargs.setdefault('name')

                media_obj = self.save_media_obj(
                    kwargs['name'],
                    kwargs['email'],
                    kwargs['title'],
                    kwargs['description'],
                    None,
                    kwargs['file'],
                    kwargs['url'],
                )
                email.send_media_notification(media_obj)
                data = dict(success=True, redirect=url_for(action='success'))

        return data
コード例 #4
0
    def submit(self, **kwargs):
        """
        """
        kwargs.setdefault("name")

        # Save the media_obj!
        media_obj = self.save_media_obj(
            kwargs["name"], kwargs["email"], kwargs["title"], kwargs["description"], None, kwargs["file"], kwargs["url"]
        )
        email.send_media_notification(media_obj)

        # Redirect to success page!
        redirect(action="success")
コード例 #5
0
ファイル: upload.py プロジェクト: anitahitouch/mediadrop
 def submit(self, **kwargs):
     """
     """
     kwargs.setdefault('name')
     # Save the media_obj!
     media_obj = self.save_media_obj(
         kwargs['name'], kwargs['email'],
         kwargs['title'], kwargs['description'],
         None, kwargs['file'], kwargs['url'],
     )
     email.send_media_notification(media_obj)
     
     # Redirect to success page!
     redirect(action='success')
コード例 #6
0
ファイル: upload.py プロジェクト: z0x010/mediadrop
    def submit(self, **kwargs):
        """
        """
        kwargs.setdefault('name')

        # Save the media_obj!
        media_obj = self.save_media_obj(
            kwargs['name'], kwargs['email'],
            kwargs['title'], kwargs['description'],
            None, kwargs['file'], kwargs['url'],
        )
        email.send_media_notification(media_obj)

        # Redirect to success page!
        redirect(action='success')
コード例 #7
0
ファイル: upload.py プロジェクト: josuermcosta/mediadrop
    def submit(self, **kwargs):
        """
        """
        kwargs.setdefault('name')
        name = request.perm.user.display_name
        email_X = request.perm.user.email_address
        podcasts = DBSession.query(Podcast.id).filter(Podcast.author_name == name)\
                                              .filter(Podcast.id == kwargs['podcast'])\
                                              .all()
        if not podcasts:
            redirect(action='failure')

        # Save the media_obj!
        media_obj = self.save_media_obj(name, email_X, kwargs['title'],
                                        kwargs['description'], None,
                                        kwargs['file'], kwargs['podcast'])
        email.send_media_notification(media_obj)

        # Redirect to success page!
        redirect(action='success')