Exemple #1
0
class EditForm(base.EditForm):

    form_fields = form.Fields(ILatestSectionableNITFPortlet)

    label = _(u'Add latest NITF Portlet')
    description = _(u'This portlet display a list of latest NITF created. '
                    u'It allows to filter NITF from different sections.')
Exemple #2
0
class AddForm(base.AddForm):

    form_fields = form.Fields(ILatestSectionableNITFPortlet)

    label = _(u'Add latest NITF Portlet')
    description = _(u'This portlet display a list of latest NITF created. '
                    u'It allows to filter NITF from different sections.')

    def create(self, data):
        return Assignment(**data)
Exemple #3
0
    def getAvailableSections(self):
        vocab = getUtility(IVocabularyFactory,
                           name=u'collective.nitf.AvailableSections')(
                               self.context)

        values = SimpleVocabulary(
            [SimpleVocabulary.createTerm(_(u'All'), 'all', _(u'All'))] +
            vocab._terms)

        return values
    def getAvailableSections(self):
        vocab = getUtility(IVocabularyFactory,
                           name=u'collective.nitf.Sections')(self.context)

        values = SimpleVocabulary([SimpleVocabulary.createTerm(_(u"All"),
                                                               "all",
                                                               _(u"All"))] +
                                  vocab._terms)

        return values
def AvailableGenresVocabulary(context):
    """ Creates a vocabulary with the available genres stored in the registry;
    the vocabulary is normalized to allow the use of non-ASCII characters.
    """
    registry = getUtility(IRegistry)
    settings = registry.forInterface(INITFSettings)
    available_genres = list(settings.available_genres)
    available_genres.sort(key=lambda i: _(i))  # sort by translated genre
    items = []
    for genre in available_genres:
        token = _normalize_token(genre)
        items.append(SimpleVocabulary.createTerm(genre, token, _(genre)))
    return SimpleVocabulary(items)
Exemple #6
0
def AvailableGenresVocabulary(context):
    """ Creates a vocabulary with the available genres stored in the registry;
    the vocabulary is normalized to allow the use of non-ASCII characters.
    """
    registry = getUtility(IRegistry)
    settings = registry.forInterface(INITFSettings)
    available_genres = list(settings.available_genres)
    # sort by translated genre
    available_genres.sort(lambda a, b: cmp(_(a), _(b)))
    items = []
    for genre in available_genres:
        token = _normalize_token(genre)
        items.append(SimpleVocabulary.createTerm(genre, token, _(genre)))
    return SimpleVocabulary(items)
Exemple #7
0
class ILatestSectionableNITFPortlet(IPortletDataProvider):
    """
    A portlet which shows the latest NITF created and can be filtered
    by section.
    """

    header = schema.TextLine(
        title=_(u'Header'),
        description=_(u'The header for the portlet. Leave empty for none.'),
        required=False)

    limit = schema.Int(
        title=_(u'Limit'),
        description=_(u'Specify the maximum number of items to show in the '
                      u'portlet. Leave this blank to show all items.'),
        default=10,
        required=False)

    pretty_date = schema.Bool(
        title=_(u'Pretty dates'),
        description=_(u'Show dates in a pretty format (ie. "4 hours ago").'),
        default=True,
        required=False)

    filter_collection = schema.Choice(
        title=_(u'Filter collection'),
        description=_(u'Use the criteria from this collection to modify the '
                      u'search results and order.'),
        required=False,
        source=SearchableTextSourceBinder(
            {'portal_type': ('Topic', 'Collection')}, default_query='path:'))
Exemple #8
0
class ISection(model.Schema):
    """Behavior interface to make a content type support sections."""

    model.fieldset('categorization', fields=['section'])
    form.order_before(section='genre')

    # nitf/head/pubdata/@position.section
    section = schema.Choice(
        title=_(u'Section'),
        description=_(
            u'help_section',
            default=u'Named section where the item will appear.',
        ),
        vocabulary=u'collective.nitf.AvailableSections',
    )
Exemple #9
0
class INITFSettings(form.Schema):
    """ Interface for the control panel form.
    """
    form.widget(
        available_sections='z3c.form.browser.textlines.TextLinesFieldWidget')
    available_sections = schema.Set(
        title=_(u'Available Sections'),
        description=_(u'List of available sections in the site.'),
        required=True,
        default=set([DEFAULT_SECTION]),
        value_type=schema.TextLine(title=_(u'Section')),
    )

    default_section = schema.Choice(
        title=_(u'Default Section'),
        description=_(u'Section to be used as default on new items.'),
        required=True,
        vocabulary=u'collective.nitf.AvailableSections',
        default=DEFAULT_SECTION,
    )

    available_genres = schema.List(
        title=_(u'Available Genres'),
        description=_(u'Select the list of available genres in the site. '
                      u'Genres indicate a nature, journalistic or '
                      u'intellectual characteristic of items.'),
        required=True,
        default=[DEFAULT_GENRE],
        value_type=schema.Choice(vocabulary=u'collective.nitf.Genres'),
    )

    default_genre = schema.Choice(
        title=_(u'Default Genre'),
        description=_(u'Genre to be used as default on new items.'),
        required=True,
        vocabulary=u'collective.nitf.Genres',
        default=DEFAULT_GENRE,
    )

    default_urgency = schema.Choice(
        title=_(u'Default Urgency'),
        vocabulary=u'collective.nitf.Urgencies',
        required=True,
        default=config.DEFAULT_URGENCY,
    )
Exemple #10
0
 def __call__(self, context):
     registry = getUtility(IRegistry)
     settings = registry.forInterface(INITFSettings)
     items = []
     if settings.possible_genres:
         for genre in settings.possible_genres:
             token = unicodedata.normalize('NFKD', genre).encode('ascii', 'ignore').lower()
             items.append(SimpleVocabulary.createTerm(genre, token, _(genre)))
     return SimpleVocabulary(items)
Exemple #11
0
class INITFTile(IBasicTile):
    """A tile that shows information about a News Article."""

    subtitle = schema.Text(
        title=_(u'Subtitle'),
        required=False,
    )

    form.omitted('section')
    form.no_omit(IDefaultConfigureForm, 'section')
    section = schema.Text(
        title=_(u'Section'),
        required=False,
    )

    media_producer = schema.TextLine(
        # nitf/body/body.content/media/media-producer
        title=_(u'Image Rights'),
        required=False,
    )
Exemple #12
0
    def decoratorFactory(self, node):
        new_node = super(NITFTreeStrategy, self).decoratorFactory(node)
        # Pongamos la fecha en un objeto "usable"
        new_node['creation_date'] = DateTime(new_node['creation_date'])
        # Y agregamos la sección del NITF
        new_node['section'] = getattr(node['item'], 'section', '')
        # el género hay que traducirlo
        new_node['genre'] = getattr(node['item'], 'genre', '')
        if new_node['genre'] != '':
            new_node['genre'] = _(new_node['genre'])

        return new_node
Exemple #13
0
class NITFTile(BasicTile):
    """A tile that shows information about a News Article."""

    index = ViewPageTemplateFile('nitf.pt')
    is_configurable = True
    is_editable = True
    is_droppable = True

    short_name = _(u'msg_short_name_nitf', u'News Article')

    def accepted_ct(self):
        """Return a list of content types accepted by the tile."""
        return ['collective.nitf.content']

    def populate_with_object(self, obj):
        super(BasicTile, self).populate_with_object(obj)

        if INITF.providedBy(obj):
            image = obj.image()
            data = dict(
                title=obj.title,
                description=obj.description,
                subtitle=obj.subtitle,
                section=obj.section,
                uuid=IUUID(obj),
                date=True,
                subjects=True,
                image=self.get_image_data(image),
                media_producer=obj.media_producer(),
            )
            # clear scales as new image is getting saved
            self.clear_scales()

            data_mgr = ITileDataManager(self)
            data_mgr.set(data)

    def _get_field_configuration(self, field):
        """Return a dict with the configuration of the field. This is a
        helper function to deal with the ugliness of the internal data
        structure.
        """
        fields = self.get_configured_fields()
        return [f for f in fields if f['id'] == field][0]

    @property
    def title_tag(self):
        field = self._get_field_configuration('title')
        tag, title, href = field['htmltag'], field['content'], self.getURL()
        return u"""
            <{tag}>
              <a href="{href}">{title}</a>
            </{tag}>
            """.format(tag=tag, title=title, href=href)
Exemple #14
0
class INITF(model.Schema):
    """A News Article based on the News Industry Text Format specification."""

    # title = schema.TextLine()
    # nitf/head/title and nitf/body/body.head/hedline/hl1

    form.order_before(subtitle='IDublinCore.title')
    subtitle = schema.TextLine(
        # nitf/body/body.head/hedline/hl2
        title=_(u'Subtitle'),
        description=_(u'help_subtitle',
                      default=u'A subordinate headline for the article.'),
        default=u'',
        missing_value=u'',
        required=False,
    )

    byline = schema.TextLine(
        # nitf/body/body.head/byline/person
        title=_(u'Author'),
        default=u'',
        missing_value=u'',
        required=False,
    )

    location = schema.TextLine(
        # nitf/body/body.head/dateline/location
        title=_(u'Location'),
        description=_(
            u'help_location',
            default=u'Event location. Where an event took place '
            u'(as opposed to where the story was written).',
        ),
        default=u'',
        missing_value=u'',
        required=False,
    )

    text = RichText(
        # nitf/body/body.content
        title=_(u'Body text'),
        required=False,
    )

    model.fieldset('categorization', fields=['genre', 'urgency'])

    genre = schema.Choice(
        # nitf/head/tobject/tobject.property/@tobject.property.type
        title=_(u'Genre'),
        description=_(
            u'help_genre',
            default=u'Describes the nature, journalistic or '
            u'intellectual characteristic of a news '
            u'object, not specifically its content.',
        ),
        vocabulary=u'collective.nitf.AvailableGenres',
        defaultFactory=genre_default_value)

    urgency = schema.Choice(
        # nitf/head/docdata/urgency/@ed-urg
        title=_(u'Urgency'),
        description=_(u'help_urgency', default=u'News importance.'),
        vocabulary=u'collective.nitf.Urgencies',
        defaultFactory=urgency_default_value)
Exemple #15
0
# -*- coding: utf-8 -*-

PROJECTNAME = 'collective.nitf'

from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from collective.nitf import _

# this cames from http://cv.iptc.org/newscodes/genre/
GENRES = SimpleVocabulary([
    SimpleTerm(value=u'Actuality',
               title=_(u'Actuality')),
    # Definition: The object contains the recording of the event.
    SimpleTerm(value=u'Advice',
               title=_(u'Advice')),
    # Definition: The object contains advice, typically letters and answers about personal problems, that are publishable.
    SimpleTerm(value=u'Almanac',
               title=_(u'Almanac')),
    # Definition: List of data, including birthdays of famous people and items of historical significance, for a given day.
    SimpleTerm(value=u'Analysis',
               title=_(u'Analysis')),
    # Definition: The object contains data and conclusions drawn by a journalist who has researched the story in depth.
    SimpleTerm(value=u'Anniversary',
               title=_(u'Anniversary')),
    # Definition: Stories about the anniversary of some important event that took place in recent history, usually bringing a short review of the event itself.
    SimpleTerm(value=u'Archive material',
               title=_(u'Archive material')),
    # Definition: The object contains material distributed previously that has been selected from the originator's archives.
    SimpleTerm(value=u'Background',
               title=_(u'Background')),
    # Definition: The object provides some scene setting and explanation for the event being reported.
Exemple #16
0
class NITFSettingsEditForm(controlpanel.RegistryEditForm):
    schema = INITFSettings
    label = _(u'NITF Settings')
    description = _(u'Here you can modify the settings for collective.nitf.')
Exemple #17
0
# -*- coding: utf-8 -*-
from collective.nitf import _
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

PROJECTNAME = "collective.nitf"

# this cames from http://cv.iptc.org/newscodes/genre/
GENRES = SimpleVocabulary(
    [
        SimpleTerm(value=u"Actuality", title=_(u"Actuality")),
        # Definition: The object contains the recording of the event.
        SimpleTerm(value=u"Advice", title=_(u"Advice")),
        # Definition: The object contains advice, typically letters and answers
        # about personal problems, that are publishable.
        SimpleTerm(value=u"Almanac", title=_(u"Almanac")),
        # Definition: List of data, including birthdays of famous people and items
        # of historical significance, for a given day.
        SimpleTerm(value=u"Analysis", title=_(u"Analysis")),
        # Definition: The object contains data and conclusions drawn by a
        # journalist who has researched the story in depth.
        SimpleTerm(value=u"Anniversary", title=_(u"Anniversary")),
        # Definition: Stories about the anniversary of some important event that
        # took place in recent history, usually bringing a short review of the
        # event itself.
        SimpleTerm(value=u"Archive material", title=_(u"Archive material")),
        # Definition: The object contains material distributed previously that has
        # been selected from the originator's archives.
        SimpleTerm(value=u"Background", title=_(u"Background")),
        # Definition: The object provides some scene setting and explanation for
        # the event being reported.
Exemple #18
0
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen. Here, we use the title that the user gave.
     """
     return _(u'Latest Sectionable NITF')
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen. Here, we use the title that the user gave.
     """
     return _(u"Latest Sectionable NITF")
# -*- coding: utf-8 -*-

PROJECTNAME = 'collective.nitf'
CONTROLPANEL_ID = 'nitf-settings'

from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from collective.nitf import _

NEWS_TYPES = SimpleVocabulary([
    SimpleTerm(value=u'Analysis',
               title=_(u'Analysis')),
    SimpleTerm(value=u'Archive-Material',
               title=_(u'Archive-Material')),
    SimpleTerm(value=u'Background',
               title=_(u'Background')),
    SimpleTerm(value=u'Current',
               title=_(u'Current')),
    SimpleTerm(value=u'Feature',
               title=_(u'Feature')),
    SimpleTerm(value=u'Forecast',
               title=_(u'Forecast')),
    SimpleTerm(value=u'History',
               title=_(u'History')),
    SimpleTerm(value=u'Obituary',
               title=_(u'Obituary')),
    SimpleTerm(value=u'Opinion',
               title=_(u'Opinion')),
    SimpleTerm(value=u'Polls-Surveys',
               title=_(u'Polls-Surveys')),
    SimpleTerm(value=u'Profile',
Exemple #21
0
# -*- coding: utf-8 -*-
from collective.nitf import _
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

PROJECTNAME = 'collective.nitf'

# this cames from http://cv.iptc.org/newscodes/genre/
GENRES = SimpleVocabulary([
    SimpleTerm(value=u'Actuality', title=_(u'Actuality')),
    # Definition: The object contains the recording of the event.
    SimpleTerm(value=u'Advice', title=_(u'Advice')),
    # Definition: The object contains advice, typically letters and answers
    # about personal problems, that are publishable.
    SimpleTerm(value=u'Almanac', title=_(u'Almanac')),
    # Definition: List of data, including birthdays of famous people and items
    # of historical significance, for a given day.
    SimpleTerm(value=u'Analysis', title=_(u'Analysis')),
    # Definition: The object contains data and conclusions drawn by a
    # journalist who has researched the story in depth.
    SimpleTerm(value=u'Anniversary', title=_(u'Anniversary')),
    # Definition: Stories about the anniversary of some important event that
    # took place in recent history, usually bringing a short review of the
    # event itself.
    SimpleTerm(value=u'Archive material', title=_(u'Archive material')),
    # Definition: The object contains material distributed previously that has
    # been selected from the originator's archives.
    SimpleTerm(value=u'Background', title=_(u'Background')),
    # Definition: The object provides some scene setting and explanation for
    # the event being reported.
    SimpleTerm(value=u'Current', title=_(u'Current')),