当前位置: 首页>>代码示例>>Python>>正文


Python Media.reviewed方法代码示例

本文整理汇总了Python中mediacore.model.Media.reviewed方法的典型用法代码示例。如果您正苦于以下问题:Python Media.reviewed方法的具体用法?Python Media.reviewed怎么用?Python Media.reviewed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mediacore.model.Media的用法示例。


在下文中一共展示了Media.reviewed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _new_publishable_media

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import reviewed [as 别名]
 def _new_publishable_media(self, slug, name):
     from datetime import datetime
     from mediacore.model import Author, Media
     media = Media()
     media.slug = slug
     media.title = name
     media.subtitle = None
     media.description = u"""<p>Description</p>"""
     media.description_plain = u"""Description"""
     media.author = Author(u'fake name', u'[email protected]')
     media.publish_on = datetime.now()
     media.publishable = True
     media.reviewed = True
     media.encoded = False
     media.type = None
     return media
开发者ID:MechanisM,项目名称:mediacore,代码行数:18,代码来源:__init__.py

示例2: uploadThumb

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import reviewed [as 别名]
    def uploadThumb(self, thumb_file, podcastid, reviewed=False, **kwargs):
        """Save a thumbnail uploaded with :class:`~mediacore.forms.admin.ThumbForm`.
 
        :param file: The uploaded file
        :type file: :class:`cgi.FieldStorage` or ``None``
        :rtype: JSON dict
        :returns:
            success
                bool
            message
                Error message, if unsuccessful
            id
                The :attr:`~mediacore.model.media.Media.id` which is
                important if a new media has just been created.

        """ 
        media = Media() 
	media.author =  Author('user', '[email protected]')
	media.title = os.path.basename(thumb_file.filename)
	media.slug = get_available_slug(Media, '_stub_' + media.title)
	media.reviewed = reviewed
	media.views = podcastid
	DBSession.add(media)
	DBSession.flush() 
	
        try:
            # Create JPEG thumbs
            create_thumbs_for(media, thumb_file.file, thumb_file.filename)
            success = True
            message = None
        except IOError, e:
            success = False
            if id == 'new':
                DBSession.delete(media)
            if e.errno == 13:
                message = _('Permission denied, cannot write file')
            elif e.message == 'cannot identify image file':
                message = _('Unsupport image type: %s') \
                    % os.path.splitext(thumb_file.filename)[1].lstrip('.')
            elif e.message == 'cannot read interlaced PNG files':
                message = _('Interlaced PNGs are not supported.')
            else:
                raise
开发者ID:,项目名称:,代码行数:45,代码来源:

示例3: add_file

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import reviewed [as 别名]
    def add_file(self, id, file=None, url=None, **kwargs):
        """Save action for the :class:`~mediacore.forms.admin.media.AddFileForm`.

        Creates a new :class:`~mediacore.model.media.MediaFile` from the
        uploaded file or the local or remote URL.

        :param id: Media ID. If ``"new"`` a new Media stub is created.
        :type id: :class:`int` or ``"new"``
        :param file: The uploaded file
        :type file: :class:`cgi.FieldStorage` or ``None``
        :param url: A URL to a recognizable audio or video file
        :type url: :class:`unicode` or ``None``
        :rtype: JSON dict
        :returns:
            success
                bool
            message
                Error message, if unsuccessful
            media_id
                The :attr:`~mediacore.model.media.Media.id` which is
                important if new media has just been created.
            file_id
                The :attr:`~mediacore.model.media.MediaFile.id` for the newly
                created file.
            edit_form
                The rendered XHTML :class:`~mediacore.forms.admin.media.EditFileForm`
                for this file.
            status_form
                The rendered XHTML :class:`~mediacore.forms.admin.media.UpdateStatusForm`

        """
        if id == 'new':
            media = Media()
            user = request.environ['repoze.who.identity']['user']
            media.author = Author(user.display_name, user.email_address)
            # Create a temp stub until we can set it to something meaningful
            timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            media.title = u'Temporary stub %s' % timestamp
            media.slug = get_available_slug(Media, '_stub_' + timestamp)
            media.reviewed = True
            DBSession.add(media)
            DBSession.flush()
        else:
            media = fetch_row(Media, id)

        media_file = add_new_media_file(media, file, url)
        if media.slug.startswith('_stub_'):
            media.title = media_file.display_name
            media.slug = get_available_slug(Media, '_stub_' + media.title)

        # The thumbs may have been created already by add_new_media_file
        if id == 'new' and not has_thumbs(media):
            create_default_thumbs_for(media)

        media.update_status()

        # Render some widgets so the XHTML can be injected into the page
        edit_form_xhtml = unicode(edit_file_form.display(
            action=url_for(action='edit_file', id=media.id),
            file=media_file))
        status_form_xhtml = unicode(update_status_form.display(
            action=url_for(action='update_status', id=media.id),
            media=media))

        data = dict(
            success = True,
            media_id = media.id,
            file_id = media_file.id,
            file_type = media_file.type,
            edit_form = edit_form_xhtml,
            status_form = status_form_xhtml,
            title = media.title,
            slug = media.slug,
            description = media.description,
            link = url_for(action='edit', id=media.id),
            duration = helpers.duration_from_seconds(media.duration),
        )

        return data
开发者ID:,项目名称:,代码行数:81,代码来源:

示例4: add_default_data

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import reviewed [as 别名]

#.........这里部分代码省略.........

    edit_perm = Permission(name=u'edit', groups=[admin_group, editor_group], 
        description=u'Grants access to edit site content')
    DBSession.add(edit_perm)

    category = Category(name=u'Featured', slug=u'featured')
    DBSession.add(category)

    category2 = Category(name=u'Instructional', slug=u'instructional')
    DBSession.add(category2)

    podcast = Podcast()
    podcast.slug = u'hello-world'
    podcast.title = u'Hello World'
    podcast.subtitle = u'My very first podcast!'
    podcast.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
    podcast.category = u'Technology'
    podcast.author = Author(admin_user.display_name, admin_user.email_address)
    podcast.explicit = None
    podcast.copyright = u'Copyright 2009 Xyz'
    podcast.itunes_url = None
    podcast.feedburner_url = None
    DBSession.add(podcast)

    comment = Comment()
    comment.subject = u'Re: New Media'
    comment.author = AuthorWithIP(name=u'John Doe', ip=2130706433)
    comment.body = u'<p>Hello to you too!</p>'
    DBSession.add(comment)

    media = Media()
    media.type = None
    media.slug = u'new-media'
    media.reviewed = True
    media.encoded = False
    media.publishable = False
    media.title = u'New Media'
    media.subtitle = None
    media.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
    media.description_plain = u"""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
    media.author = Author(admin_user.display_name, admin_user.email_address)
    media.categories.append(category)
    media.comments.append(comment)
    DBSession.add(media)

    #XXX The list of default players is actually defined in model.players
    # and should at some point be moved here to avoid inconsistency
    # between the default storage engines and default players.
    remote_url_storage = RemoteURLStorage()
    default_engines = [
        LocalFileStorage(),
        remote_url_storage,
        YoutubeStorage(),
        VimeoStorage(),
        BlipTVStorage(),
        DailyMotionStorage(),
        GoogleVideoStorage(),
    ]
    for engine in default_engines:
        DBSession.add(engine)

    import datetime
    instructional_media = [
        (u'workflow-in-mediacore',
        u'Workflow in MediaCore',
        u'<p>This sceencast explains the publish status feature in MediaCore.</p><p>Initially all videos uploaded through the front-end or admin panel are placed under &quot;awaiting review&quot; status. Once the administrator hits the &quot;review complete&quot; button, they can upload media. Videos can be added in any format, however, they can only be published if they are in a web-ready format such as FLV, M4V, MP3, or MP4. Alternatively, if they are published through Youtube or Vimeo the encoding step is skipped</p><p>Once uploaded and encoded the administrator can then publish the video.</p>',
开发者ID:BlendedLearningCollaborative,项目名称:mediacore-community,代码行数:70,代码来源:websetup.py

示例5: media_from_entry

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import reviewed [as 别名]
def media_from_entry(e, tags=False, save_files=False):
    # Get tags as a list of unicode objects.
    tags = [t['term'] for t in e['tags']]

    # Assume not explicit.
    explicit = 0
    if 'itunes_explicit' in e:
        explicit = e['itunes_explicit']

    # Find the duration, if it exists
    duration = u''
    if 'itunes_duration' in e:
        try:
            duration = e['itunes_duration']
            duration = duration_to_seconds(duration)
        except ValueError:
            duration = None

    # Find the first <img> tag in the summary, if there is one
    image = None
    m = img_regex.match(e['summary'])
    if m is not None:
        image = m.group(1)[1:-1]

    title = e['title']

    slug = slugify(title)
    author_name = u"PLACEHOLDER NAME"
    author_email = u"[email protected]"
    if 'author_detail' in e:
        if 'name' in e['author_detail']:
            author_name = e['author_detail']['name']
        if 'email' in e['author_detail']:
            author_email = e['author_detail']['email']
    year, month, day, hour, minute, second = e['updated_parsed'][:6]
    updated = datetime(year, month, day, hour, minute, second)

    media = Media()
    media.slug = get_available_slug(Media, slug, media)
    media.title = e['title']
    media.author = Author(author_name, author_email)
    media.description = e['summary']
    media.notes = u''
    if tags:
        media.set_tags(tags)
    else:
        media.set_categories(tags)
    media.publish_on = updated
    media.created_on = updated
    media.publishable = True
    media.reviewed = True
    media.duration = duration

    DBSession.add(media)
    DBSession.flush()

    # Create thumbs from image, or default thumbs
    created_images = False
    if image:
        temp_imagefile = tempfile.TemporaryFile()
        imagefile = urllib2.urlopen(image)
        temp_imagefile.write(imagefile.read())
        temp_imagefile.seek(0)
        filename = urlparse.urlparse(image)[2]
        create_thumbs_for(media, temp_imagefile, filename)
        created_images = True

    if not created_images:
        create_default_thumbs_for(media)

    print "Loaded episode:", media

    # now add all of the files.
    for enc in e['enclosures']:
        mf = media_file_from_enclosure(enc, media, save_files)
        print "Loaded media file:", mf

    media.update_status()

    return media
开发者ID:MechanisM,项目名称:mediacore,代码行数:82,代码来源:rss_import.py

示例6: add_default_data

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import reviewed [as 别名]

#.........这里部分代码省略.........
    media_upload_perm.groups.append(admin_group)
    media_upload_perm.groups.append(editor_group)
    media_upload_perm.groups.append(anonymous_group)
    DBSession.add(edit_perm)

    category = Category(name=u"Featured", slug=u"featured")
    DBSession.add(category)

    category2 = Category(name=u"Instructional", slug=u"instructional")
    DBSession.add(category2)

    podcast = Podcast()
    podcast.slug = u"hello-world"
    podcast.title = u"Hello World"
    podcast.subtitle = u"My very first podcast!"
    podcast.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
    podcast.category = u"Technology"
    podcast.author = Author(admin_user.display_name, admin_user.email_address)
    podcast.explicit = None
    podcast.copyright = u"Copyright 2009 Xyz"
    podcast.itunes_url = None
    podcast.feedburner_url = None
    DBSession.add(podcast)

    comment = Comment()
    comment.subject = u"Re: New Media"
    comment.author = AuthorWithIP(name=u"John Doe", ip=2130706433)
    comment.body = u"<p>Hello to you too!</p>"
    DBSession.add(comment)

    media = Media()
    media.type = None
    media.slug = u"new-media"
    media.reviewed = True
    media.encoded = False
    media.publishable = False
    media.title = u"New Media"
    media.subtitle = None
    media.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
    media.description_plain = u"""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
    media.author = Author(admin_user.display_name, admin_user.email_address)
    media.categories.append(category)
    media.comments.append(comment)
    DBSession.add(media)

    # XXX The list of default players is actually defined in model.players
    # and should at some point be moved here to avoid inconsistency
    # between the default storage engines and default players.
    remote_url_storage = RemoteURLStorage()
    default_engines = [
        LocalFileStorage(),
        remote_url_storage,
        YoutubeStorage(),
        VimeoStorage(),
        BlipTVStorage(),
        DailyMotionStorage(),
    ]
    for engine in default_engines:
        DBSession.add(engine)

    import datetime

    instructional_media = [
        (
            u"workflow-in-mediacore",
            u"Workflow in MediaCore",
开发者ID:nti1094,项目名称:mediacore-community,代码行数:70,代码来源:websetup.py


注:本文中的mediacore.model.Media.reviewed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。