Пример #1
0
    def __call__(self):
        cover = new_path = None
        try:
            cover = self.genPdfRecension()
            pdf = self.context.get_review_pdf()
            error_code = None
            new_path = None
            if pdf:
                pdf_blob = pdf["blob"]
                original = pdf_blob.open().name
                fd, new_path = tempfile.mkstemp(prefix = 'final',
                                                suffix = '.pdf')
                os.close(fd) #2463
                error_code = os.system(
                    'ulimit -t 5;pdftk %s %s cat output %s' % (
                    cover, original, new_path
                    )
                    )
            if error_code or not pdf:
                IStatusMessage(self.request).add(
                    _(u'Creating the pdf has failed! Please try again '
                      'or ask for support'),
                    'error')
                return
            else:
                pdfdata = file(new_path).read()
        finally:
            if cover:
                os.remove(cover)
            if new_path:
                os.remove(new_path)

        self._prepareHeader(len(pdfdata), "%s.pdf" % IUUID(self.context))
        return pdfdata
Пример #2
0
 def getLicense(real_self):
     self = real_self.magic
     publication = self.get_parent_object_of_type("Publication")
     publication_licence = ""
     if publication != None:
         publication_licence = getattr(publication, "licence", "")
     return True and publication_licence or _('license-note-review')
Пример #3
0
 def __call__(self, value, *args, **kwargs):
     if value != "DELETE_IMAGE":
         try:
             Image.open(value)
             value.seek(0)
             return True
         except IOError, e:
             return _(str(e))
Пример #4
0
 def __call__(self, value, *args, **kwargs):
     if value == True:
         return 1
     site = getSite()
     language = getToolByName(site,
                              'portal_languages').getPreferredLanguage()
     return translate(
         _(u'message_ccby_license',
           default=(u"All submitted reviews must be published under "
                    "the CC-BY licence.")
           ),
         target_language=language)
Пример #5
0
 def getLicense(real_self):
     self = real_self.magic
     publication = self.get_parent_object_of_type("Publication")
     publication_licence = ""
     current = self
     if publication != None:
         while current != publication:
             publication_licence = getattr(current, "licence", "")
             if publication_licence:
                 break
             current = current.aq_parent
         if not publication_licence:
             publication_licence = getattr(publication, "licence", "")
     return True and publication_licence or _('license-note-review')
Пример #6
0
 def __call__(self, value, *args, **kwargs):
     # "value" is a byte string. We need to decode it before we can
     # count the number of chars. We make the assumption that it is
     # utf-8 encoded
     html = fromstring(value.decode("utf-8"))
     # extract the text from the html
     textblocks = html.xpath("//text()")
     # join the textblocks except for line breaks (empty p tags)
     text = "".join([i for i in textblocks if i != "\r\n"])
     character_count = len(text)
     # TODO: setting the validator via the finalize_recensio_schema
     # method didn't work so I'm setting it here manually.
     is_review = kwargs["instance"]["portal_type"].startswith("Review")
     if is_review or character_count <= 6000:
         return 1
     else:
         return translate(
             _(u"message_characters_exceeded",
               default =(
             u"You have exceeded the maximum number of characters you are "
             "permitted to use.")
               )
             )
Пример #7
0
 def getLicenseURL(real_self):
     self = real_self.magic
     return {'msg' : _('license-note-presentation-url-text'),
             'url' : _('license-note-presentation-url-url')}
Пример #8
0
 def getLicense(real_self):
     self = real_self.magic
     return _('license-note-presentation')
Пример #9
0
    def _genCoverSheet(self):
        file_handle, tmpfile = tempfile.mkstemp(prefix='cover', suffix='.pdf')
        os.close(file_handle) #2463
        self.canvas = cover = canvas.Canvas(tmpfile, pagesize=A4)
        pwidth,pheight = A4

        language = self.request.get('language', '')
        # I want the syntax for translation look as similar as the real thing
        # But not similar enough for freaking out the translation string
        # extractors
        _X = lambda x: translate(x, target_language = language)
        # register the font (unicode-aware)
        font =  os.path.abspath(__file__ +\
                                '/../../data/DejaVuSerif.ttf')
        pdfmetrics.registerFont( TTFont('DejaVu-Serif', font) )

        self._drawImage('logo2_fuer-Deckblatt.jpg',
                        0,
                        pheight - 4.21*cm,
                        28.28*cm,
                        4.21*cm)

        pdf_watermark_path = resource_filename(
            __name__,
            os.path.join('images', 'logo_icon_watermark.jpg'))

        publication = self.context.get_parent_object_of_type("Publication")
        if publication != None:
            pdf_watermark_obj = getattr(publication, "pdf_watermark", None)
            if pdf_watermark_obj:
                pdf_watermark_path = pdf_watermark_obj.getBlob().open().name

        self.canvas.drawImage(
            pdf_watermark_path,
            6.2 * cm,
            9.5 * cm,
            6 * cm,
            6 * cm,
            preserveAspectRatio=True,
            anchor='sw',
            mask='auto' # To support transparent PNGs
            )
        cover.setFont('DejaVu-Serif', 10)
        cover.setFillColor(grey)
        citation = translate(_(u'label_citation_style',
                               default=u'citation style'),
                             target_language=language)
        cover.drawString(2.50*cm, pheight-5.5*cm, citation)
        cover.drawString(2.50*cm, pheight-21.5*cm, u'copyright')

        style = ParagraphStyle('citation style',
                               fontName = 'DejaVu-Serif',
                               fontSize = 10, textColor = grey)
        try:
            P = Paragraph(_(self.context.get_citation_string()), style)
        except UnicodeDecodeError:#ATF
            P = Paragraph(self.context.get_citation_string(), style)
        realwidth, realheight = P.wrap(pwidth-6.20*cm-2.5*cm, 10*cm)
        P.drawOn(cover, 6.20*cm, pheight-6.5*cm-realheight)
        # A small calculation, how much this paragaph would overlap
        # into the next paragraph. If the number is positive, we have
        # an overlap, and apply it to the initial offset
        overlap  = (pheight - 8.5 * cm) - (pheight - 6.5 * cm - realheight)
        overlap += 15 # padding

        if hasattr(self.context, 'getFirstPublicationData'):
            msgs = ['First published: ' + x
                    for x in self.context.getFirstPublicationData()]
            offset = max(overlap, 0)
            for msg in msgs:
                P2 = Paragraph(msg, style) # msg got escaped"
                realwidth, realheight = P2.wrap(pwidth-6.20*cm-2.5*cm, 10*cm)
                P2.drawOn(cover, 6.20*cm, pheight-8.5*cm-realheight - offset)
                offset += realheight

        P3 = Paragraph(_X(self.context.getLicense()), style)
        realwidth, realheight = P3.wrap(pwidth-6.20*cm-2.5*cm, 10*cm)
        P3.drawOn(cover, 6.20*cm, pheight-22.5*cm-realheight)

        cover.showPage()
        cover.save()
        return tmpfile
Пример #10
0
from Products.ATContentTypes.content import schemata
from recensio.contenttypes import contenttypesMessageFactory as _
from recensio.contenttypes.content.publication import PublicationSchema
from recensio.contenttypes.content.publication import Publication
from recensio.contenttypes.interfaces import IPublication
from zope.interface import implements


JournalSchema = (
    PublicationSchema.copy() +
    atapi.Schema((
        atapi.StringField(
            'issn',
            storage=atapi.AnnotationStorage(),
            widget=atapi.StringWidget(
                label=_(u"ISSN"),
                description=_(
                    u'description_issn',
                    default=(u"With or without hyphens.")
                ),
            ),
        ),
        atapi.StringField(
            'shortnameJournal',
            storage=atapi.AnnotationStorage(),
            widget=atapi.StringWidget(
                label=_(u"Shortname"),
            ),
        ),
        atapi.StringField(
            'yearOfPublication',
Пример #11
0
    PageStartEndOfReviewInJournalSchema, ReviewSchema,
    finalize_recensio_schema)
from recensio.contenttypes.interfaces import IReviewJournal

ReviewJournalSchema = JournalReviewSchema.copy() + \
                      CoverPictureSchema.copy() + \
                      PageStartEndInPDFSchema.copy() + \
                      PageStartEndOfReviewInJournalSchema.copy() + \
                      ReviewSchema.copy() + \
                      atapi.Schema((
    atapi.StringField(
        'editor',
        schemata="reviewed_text",
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"Editor (name or institution)"),
            ),
        ),
))

ReviewJournalSchema['title'].storage = atapi.AnnotationStorage()

ReviewJournalSchema['title'].widget.label = _(u"Title (journal)")
ReviewJournalSchema['subtitle'].widget.visible={
    "view":"hidden", "edit":"hidden"}
finalize_recensio_schema(ReviewJournalSchema)

class ReviewJournal(BaseReview):
    """Review Journal"""
    implements(IReviewJournal)
from recensio.theme.browser.views import editorTypes

PresentationMonographSchema = BookReviewSchema.copy() + \
                              CoverPictureSchema.copy() + \
                              EditorialSchema.copy() + \
                              PagecountSchema.copy() + \
                              PresentationSchema.copy() + \
                              ReferenceAuthorsSchema.copy() + \
                              SerialSchema.copy() + \
                              atapi.Schema((
    atapi.TextField(
        'tableOfContents',
        schemata="presentation text",
        storage=atapi.AnnotationStorage(),
        widget=atapi.TextAreaWidget(
            label=_(u"Table of contents of the monograph you are presenting"),
            rows=9,
            ),
        ),

    DataGridField(
        'existingOnlineReviews',
        schemata=u"presentation",
        storage=atapi.AnnotationStorage(),
        columns=("name", "url"),
        default=[{'name':'', 'url':''}],
        widget=DataGridWidget(
            label = _(u"Existing online reviews"),
            description=_(
    u'description_existing_online_reviews',
    default=(u"Are there reviews on your text which are already available "
Пример #13
0
 def get_metadata(self):
     context = self.context
     fields = self.context.Schema()._fields
     meta = {}
     for field in context.metadata_fields:
         value = False # A field is only displayed if it has a value
         is_macro = False
         if field.startswith("get_"):
             label = self.custom_metadata_field_labels[field]
             value = context[field]()
         elif field == "metadata_start_end_pages":
             label = _("metadata_pages")
             value = context.page_start_end_in_print
         elif field == "metadata_review_author":
             label = _("label_metadata_review_author")
             value = self.list_rows(
                 context["reviewAuthors"], "lastname", "firstname")
         elif field == "metadata_presentation_author":
             label = _("label_metadata_presentation_author")
             value = self.list_rows(
                 context["reviewAuthors"], "lastname", "firstname")
         elif field == "authors":
             label = self.get_label(fields, field, context.meta_type)
             value = self.list_rows(context[field], "lastname", "firstname")
         elif field == "editorial":
             label = self.get_label(fields, field, context.meta_type)
             value = self.list_rows(context[field], "lastname", "firstname")
         elif field == "editorsCollectedEdition":
             label = self.get_label(fields, field, context.meta_type)
             value = self.list_rows(context[field], "lastname", "firstname")
         elif field == "metadata_review_type_code":
             label = _("metadata_review_type_code")
             value = context.translate(context.portal_type)
         elif field == "referenceAuthors":
             label = _("label_metadata_reference_authors")
             value = self.list_rows(context[field],
                                    "lastname", "firstname")
         elif field == "institution":
             label = _("label_metadata_institution")
             value = self.list_rows(context[field], "name")
         elif field == "metadata_recensioID":
             label = _("metadata_recensio_id")
             value = context.UID()
         elif field == 'canonical_uri':
             url = context.canonical_uri
             if url:
                 label = self.get_label(fields, field, context.meta_type)
                 value = ('<a rel="canonical_uri" href="%s">%s</a>'
                          % (url, url))
         elif field == 'uri':
             url = context.uri
             if url:
                 label = self.get_label(fields, field, context.meta_type)
                 value = ('<a href="%s">%s</a>'
                          % (url, url))
         elif field == 'doi':
             try:
                 doi_active = self.context.isDoiRegistrationActive()
             except AttributeError:
                 doi_active = False
             # If DOI registration is not active and the object has only the
             # auto-generated DOI, i.e. the user has not supplied their own,
             # then we don't want to show the DOI. See #12126-86
             if not doi_active and context.getDoi() == context.generateDoi():
                 value = False
             else:
                 doi = context.getDoi()
                 label = self.get_label(fields, field, context.meta_type)
                 value = ('<a rel="doi" href="http://dx.doi.org/%s">%s</a>'
                         % (doi, doi))
         else:
             if field == "ddcSubject":
                 label = _("Subject classification")
             elif field == "ddcTime":
                 label = _("Time classification")
             elif field == "ddcPlace":
                 label = _("Regional classification")
             else:
                 label = self.get_label(fields, field, context.meta_type)
             # The macro is used in the template, the value is
             # used to determine whether to display that row or not
             value = context[field] and True or False
             is_macro = True
         meta[field] = {'label': label,
                        'value': value,
                        'is_macro': is_macro}
     return meta
Пример #14
0
 def __call__(self, value, *args, **kwargs):
     name = value[0]
     if name.get("firstname", "") == name.get("lastname", "") == "":
         return _("message_at_least_one_author_validation_error")
     return True
Пример #15
0
 def get_metadata(self):
     context = self.context
     fields = self.context.Schema()._fields
     meta = {}
     for field in context.metadata_fields:
         value = False # A field is only displayed if it has a value
         is_macro = False
         if field.startswith("get_"):
             label = self.custom_metadata_field_labels[field]
             value = context[field]()
         elif field == "metadata_start_end_pages":
             label = _("metadata_pages")
             value = context.page_start_end_in_print
         elif field == "metadata_review_author":
             label = _("label_metadata_review_author")
             value = self.list_rows(
                 context["reviewAuthors"], "lastname", "firstname")
         elif field == "metadata_presentation_author":
             label = _("label_metadata_presentation_author")
             value = self.list_rows(
                 context["reviewAuthors"], "lastname", "firstname")
         elif field == "authors":
             label = self.get_label(fields, field, context.meta_type)
             value = self.list_rows(context[field], "lastname", "firstname")
         elif field == "editorial":
             label = self.get_label(fields, field, context.meta_type)
             value = self.list_rows(context[field], "lastname", "firstname")
         elif field == "editorsCollectedEdition":
             label = self.get_label(fields, field, context.meta_type)
             value = self.list_rows(context[field], "lastname", "firstname")
         elif field == "metadata_review_type_code":
             label = _("metadata_review_type_code")
             value = context.translate(context.portal_type)
         elif field == "referenceAuthors":
             label = _("label_metadata_reference_authors")
             value = self.list_rows(context[field],
                                    "lastname", "firstname")
         elif field == "institution":
             label = _("label_metadata_institution")
             value = self.list_rows(context[field], "name")
         elif field == "metadata_recensioID":
             label = _("metadata_recensio_id")
             value = context.UID()
         elif field == 'canonical_uri':
             url = context.canonical_uri
             if url:
                 label = self.get_label(fields, field, context.meta_type)
                 value = ('<a rel="canonical_uri" href="%s">%s</a>'
                          % (url, url))
         elif field == 'uri':
             url = context.uri
             if url:
                 label = self.get_label(fields, field, context.meta_type)
                 value = ('<a href="%s">%s</a>'
                          % (url, url))
         elif field == 'doi':
             doi_url = self.get_doi_url_if_active()
             if doi_url:
                 value = ('<a rel="doi" href="%s">%s</a>' %
                         (doi_url, context.getDoi()))
                 label = self.get_label(fields, field, context.meta_type)
             else:
                 label = None
         else:
             if field == "ddcSubject":
                 label = _("Subject classification")
             elif field == "ddcTime":
                 label = _("Time classification")
             elif field == "ddcPlace":
                 label = _("Regional classification")
             else:
                 label = self.get_label(fields, field, context.meta_type)
             # The macro is used in the template, the value is
             # used to determine whether to display that row or not
             value = context[field] and True or False
             is_macro = True
         meta[field] = {'label': label,
                        'value': value,
                        'is_macro': is_macro}
     return meta
from recensio.contenttypes.interfaces import IPresentationArticleReview


PresentationArticleReviewSchema = (
    AuthorsSchema.copy()
    + JournalReviewSchema.copy()
    + PresentationSchema.copy()
    + ReferenceAuthorsSchema.copy()
    + PageStartEndOfPresentedTextInPrintSchema.copy()
    + atapi.Schema(
        (
            atapi.StringField(
                "heading_information_journal",
                schemata="reviewed_text",
                widget=atapi.LabelWidget(
                    label=_(u"heading_information_journal", default=(u"Information on the journal"))
                ),
            ),
            atapi.StringField(
                "titleJournal",
                storage=atapi.AnnotationStorage(),
                required=True,
                widget=atapi.StringWidget(label=_(u"title_journal", default=u"Title (Journal)")),
            ),
        )
    )
)

PresentationArticleReviewSchema["title"].storage = atapi.AnnotationStorage()
PresentationArticleReviewSchema["authors"].widget.label = _(
    "label_presentation_article_authors", default=u"Author(s) of presented article"
    def get_citation_string(real_self):
        """
        I think the in... part does not make sense for this content type
        Either return the custom citation or the generated one
        >>> from mock import Mock
        >>> at_mock = Mock()
        >>> at_mock.get = lambda x: None
        >>> at_mock.formatted_authors_editorial = u"Gerken\u2665, Patrick\u2665 / Pilz, Alexander"
        >>> at_mock.title = "Plone 4.0♥?"
        >>> at_mock.subtitle = "Das Benutzerhandbuch♥"
        >>> at_mock.reviewAuthors = [{'firstname' : 'Cillian♥', 'lastname'  : 'de Roiste♥'}]
        >>> at_mock.yearOfPublication = '2009♥'
        >>> at_mock.publisher = 'SYSLAB.COM GmbH♥'
        >>> at_mock.placeOfPublication = 'München♥'
        >>> at_mock.portal_url = lambda :'http://www.syslab.com'
        >>> at_mock.UID = lambda :'12345'
        >>> presentation = PresentationMonographNoMagic(at_mock)
        >>> presentation.directTranslate = lambda m: m.default
        >>> presentation.get_citation_string()
        u'de Roiste\u2665, Cillian\u2665: presentation of: Gerken\u2665, Patrick\u2665 / Pilz, Alexander, Plone 4.0\u2665? Das Benutzerhandbuch\u2665, M\\xfcnchen\u2665: SYSLAB.COM GmbH\u2665, 2009\u2665, <a href="http://syslab.com/r/12345">http://syslab.com/r/12345</a>'


        [Präsentator Nachname], [Präsentator Vorname]: presentation of: [Werkautor Nachname], [Werkautor Vorname], [Werktitel]. [Werk-Untertitel], [Erscheinungsort]: [Verlag], [Jahr], URL recensio.

        Big chunk removed, since it is not a review from a mag in: [Zs-Titel], [Nummer], [Heftnummer (gezähltes Jahr/Erscheinungsjahr)],

        Meier, Hans: presentation of: Meier, Hans, Geschichte des Abendlandes. Ein Abriss, München: Oldenbourg, 2010, in: Zeitschrift für Geschichte, 39, 3 (2008/2009), www.recensio.net/##

        """
        self = real_self.magic
        args = {
            'presentation_of' : real_self.directTranslate(Message(
                    u"text_presentation_of", "recensio",
                    default="presentation of:")),
            'in'              : real_self.directTranslate(Message(
                    u"text_in", "recensio", default="in:")),
            'page'            : real_self.directTranslate(Message(
                    u"text_pages", "recensio", default="p.")),
            ':'               : real_self.directTranslate(Message(
                    u"text_colon", "recensio", default=":")),
            }
        rezensent = getFormatter(u', ')
        if self.title[-1] in '!?:;.,':
            title_subtitle = getFormatter(u' ')
        else:
            title_subtitle = getFormatter(u'. ')

        item = getFormatter(u', ', u', ', u'%(:)s ' % args, u', ')
        mag_number_and_year = getFormatter(u', ', u', ', u' ')
        if False:
            _("presentation of")
        full_citation_inner = getFormatter(
            u'%(:)s %(presentation_of)s ' % args, u', ')
        rezensent_string = rezensent(
            self.reviewAuthors[0]["lastname"],
            self.reviewAuthors[0]["firstname"])
        authors_string = self.formatted_authors_editorial
        title_subtitle_string = title_subtitle(self.title, self.subtitle)
        item_string = item(
            authors_string, title_subtitle_string,
            self.placeOfPublication, self.publisher,
            self.yearOfPublication)
        return full_citation_inner(
            escape(rezensent_string), escape(item_string),
            real_self.getUUIDUrl())
Пример #18
0
                     "reviewAuthorLastname", "reviewAuthorFirstname"]

    for field in hidden_fields:
        schema[field].widget.condition = 'python:False'

    schemata.marshall_register(schema)

AuthorsSchema = atapi.Schema((
    DataGridField(
        'authors',
        schemata="reviewed_text",
        storage=atapi.AnnotationStorage(),
        columns=("lastname", "firstname"),
        default=[{'lastname':'', 'firstname':''}],
        widget=DataGridWidget(
            label = _(u"Authors"),
            columns = {"lastname" : Column(_(u"Last name")),
                       "firstname" : Column(_(u"First name")),
                       }
            ),
        searchable=True,
        ),
    ))

class isTrue:
    """
    Custom validator to ensure that the isLicenceApproved box is checked
    """
    implements(IValidator)
    name = "is_true_validator"
#        default=u"Provider of presented resource (name/institution)"
#                ),
#            description=_(u"Institution"),
#            columns = {"lastname" : Column(_(u"Last name")),
#                       "firstname" : Column(_(u"First name")),
#                       },
#            ),
#        ),
    DataGridField(
        'institution',
        storage=atapi.AnnotationStorage(),
        columns=("name",),
        default=[{'name':'',}],
        widget=DataGridWidget(
            label=_(
        u'description_institution',
        default=u"Provider of presented resource (name/institution)"
                ),
            description=_(u"Institution"),
            columns = {"name" : Column(""),
                       },
            ),
        ),
    atapi.StringField(
        'labelwidget_categories',
        widget=atapi.LabelWidget(
            label=_(
    u"label_online_resource_categories",
    default=(u"Please use the following menu to describe the contents and "
             "services of the resource. In each menu you can choose several "
             "categories.")
    )
Пример #20
0
    def get_label(self, fields, field, meta_type):
        """ Return the metadata label for a field of a particular
        portal_type
        """

        if field == "officialYearOfPublication":
                return _(u"label_metadata_official_year_of_publication",
                         default=u"Official year of publication")

        if meta_type.startswith("Review"):
            if field == "languageReview":
                return _(u"label_metadata_language_review",
                         default=u"Language (review)")
        elif meta_type.startswith("Presentation"):
            if field == "languageReview":
                return _(u"label_metadata_language_presentation",
                         default=u"Language (presentation)")
        if meta_type in ["ReviewMonograph", "PresentationMonograph"]:
            if field == "languageReviewedText":
                return _(u"label_metadata_language_monograph",
                         default=u"Language (monograph)")
            if field == "authors":
                return _(u"Author (monograph)",
                         default=u"Author (monograph)")
            if field == "editorial":
                return _(u"Editor (monograph)",
                         default=u"Editor (monograph)")
        elif meta_type in ["PresentationArticleReview",
                           "PresentationCollection"]:
            if field == "languageReviewedText":
                return _(u"label_metadata_language_article",
                         default=u"Language (article)")
            if field == "authors":
                return _(u"label_metadata_author_article",
                         default=u"Author (article)")
            if field == "editorial":
                return _(u"label_metadata_editor_article",
                         default=u"Editor (article)")
            if field == "title":
                return _(u"label_metadata_title_article",
                         default=u"Title (article)")
            if field == "titleCollectedEdition":
                return _(u"label_metadata_title_edited_volume",
                         default=u"Title (edited volume)")
        elif meta_type == "PresentationOnlineResource":
            if field == "title":
                return _(u"label_metadata_name_resource",
                         default=u"Name (Internet resource)")
            if field == "languageReviewedText":
                return _(u"label_metadata_language_internet_resource",
                         default=u"Language (Internet resource)")
        elif meta_type == "ReviewJournal":
            if field == "languageReviewedText":
                return _(u"label_metadata_language_review_journal",
                         default=u"Language (Journal)")
            if field == "editor":
                return _(u"label_metadata_editor",
                         default=u"Editor")

        return _(fields[field].widget.label)
Пример #21
0
from Products.DataGridField.Column import Column
from recensio.contenttypes import contenttypesMessageFactory as _
from recensio.contenttypes.content.publication import PublicationSchema
from recensio.contenttypes.content.publication import Publication
from recensio.contenttypes.interfaces import IPublication
from zope.interface import implements


EditedVolumeSchema = (
    PublicationSchema.copy() +
    atapi.Schema((
        atapi.StringField(
            'isbn',
            storage=atapi.AnnotationStorage(),
            widget=atapi.StringWidget(
                label=_(u"ISBN"),
                description=_(
                    u'description_isbn',
                    default=(
                        u"With or without hyphens. In case of several numbers please "
                        "choose the hard cover edition.")
                ),
            ),
        ),
        DataGridField(
            'editorial',
            storage=atapi.AnnotationStorage(),
            columns=("lastname", "firstname"),
            default=[{'lastname':'', 'firstname':''}],
            widget=DataGridWidget(
                label=_(u"label_editorial"),
Пример #22
0
from recensio.contenttypes import contenttypesMessageFactory as _

from recensio.contenttypes.interfaces import IVolume
from recensio.contenttypes.config import PROJECTNAME
from recensio.contenttypes.content.schemata import LicenceSchema

DoiSettingsSchema = atapi.Schema((

    atapi.BooleanField(
        'doiRegistrationActive',
        accessor='isDoiRegistrationActive',
        storage=atapi.AnnotationStorage(),
        default=True,
        widget=atapi.BooleanWidget(
            label=_(u"Activate DOI registration"),
            description=_(
                u'description_activate_doi_registration',
                default=(u"Activates the registration of DOIs at da|ra"),
            ),
        ),
    ),

))

FulltextSettingsSchema = atapi.Schema((

    atapi.BooleanField(
        'useExternalFulltext',
        accessor='isUseExternalFulltext',
        storage=atapi.AnnotationStorage(),
Пример #23
0
# -*- Message Factory Imported Here -*-

from recensio.contenttypes import contenttypesMessageFactory as _
from recensio.contenttypes.interfaces import IPublication
from recensio.contenttypes.config import PROJECTNAME

PublicationSchema = folder.ATFolderSchema.copy() + \
    atapi.Schema((

    atapi.BooleanField(
        'useCanonicalUriForBVID',
        accessor='isUseCanonicalUriForBVID',
        storage=atapi.AnnotationStorage(),
        default=False,
        widget=atapi.BooleanWidget(
            label=_(u"Original-URL für BVID-Export"),
            description=_(
                u'description_use_canonical_for_bvid',
                default=(u"Benutze die Original-URL von Rezensionen dieser "
                         "Zeitschrift im BVID-Export. Ist diese Option "
                         "deaktiviert wird die recensio.net-URL verwendet."),
            ),
        ),
    ),

)) + LicenceSchema.copy()

# Set storage on fields copied from ATFolderSchema, making sure
# they work well with the python bridge properties.

PublicationSchema['title'].storage = atapi.AnnotationStorage()
Пример #24
0
def finalize_recensio_schema(schema, review_type="review"):
    """Custom replacement for schemata.finalizeATCTSchema

    Move fields to the correct schemata and hide fields we don't need

    """

    if review_type in ["presentation", "presentation_online",
                       "presentation_article_review",
                       "presentation_collection"]:
        # Presentations only have one author
        schema["reviewAuthors"].allow_reorder = False
        schema["reviewAuthors"].allow_insert = False
        schema["reviewAuthors"].allow_delete = False
        schema["reviewAuthors"].widget.label = _(u"label_presentation_authors")
        # Rename the schemata for presentations
        presented = "presented_text"
        if review_type == "presentation_online":
            presented = "presented_resource"
        schema_field_names  = [i.getName() for i in schema.fields()]
        for field_name in schema_field_names:
            if schema[field_name].schemata == "review":
                schema.changeSchemataForField(field_name, "presentation")
            elif schema[field_name].schemata == "presentation":
                pass
            else:
                schema.changeSchemataForField(field_name, presented)
            if field_name in ["pageStart", "pageEnd"]:
                # TODO: remove after running scripts/migrate_page_start_end.py
                schema[field_name].widget.visible={
                    "view":"hidden", "edit":"hidden"}
        # Third schemata for presentations with assocatied publications
        if review_type in ["presentation_article_review",
                           "presentation_collection"]:
            if review_type == "presentation_article_review":
                associated_publication = "associated_journal"
            else:
                associated_publication = "associated_edited_volume"
            for field_name in schema_field_names:

                if field_name in ["issn", "isbn",
                                  "titleCollectedEdition",
                                  "heading_information_journal",
                                  "titleJournal", "shortnameJournal",
                                  "editorsCollectedEdition",
                                  "yearOfPublication",
                                  "officialYearOfPublication",
                                  "volumeNumber", "issueNumber",
                                  "series", "seriesVol", "pages",
                                  "placeOfPublication", "publisher",
                                  "idBvb"]:
                    schema.changeSchemataForField(field_name,
                                                  associated_publication)

        schema["uri"].widget.visible["edit"] = "visible"
        schema.changeSchemataForField("uri", presented)
        multiselect_description = _("description_ctrl_for_multiple", default=u"Mit gedrückter Strg-Taste können mehrere Zeilen gleichzeitig ausgewählt werden.")
        schema["ddcSubject"].widget.label = _(u"Subject classification")
        schema["ddcSubject"].widget.description= multiselect_description
        schema['ddcTime'].widget.label = _(u"Time classification")
        schema["ddcTime"].widget.description= multiselect_description
        schema['ddcPlace'].widget.label = _(u"Regional classification")
        schema["ddcPlace"].widget.description= multiselect_description
        # fill in the review author first name and last name by default
        # schema['reviewAuthorLastname'].default_method = "get_user_lastname"
        # schema['reviewAuthorFirstname'].default_method = "get_user_firstname"
        schema['languageReview'].widget.label = _(
            u"Language(s) of presentation")
        if review_type == "presentation_online":
            schema['languageReviewedText'].widget.label = _(
                u"Language(s) of presented resource")
        else:
            schema['languageReviewedText'].widget.label = _(
                u"Language(s) of presented work")
        # Note: The characterLimit validator checks the portal_type to
        # see if it should be applied or not. Setting it here didn't
        # seem to work
    elif review_type in ["review_monograph",
                         "review_journal"]:
        schema.changeSchemataForField('licence', 'review')

    hidden_fields = ["allowDiscussion", "contributors", "creators",
                     "description", "description", "effectiveDate",
                     "excludeFromNav", "expirationDate",
                     "generatedPdf", "id", "language", "location",
                     "recensioID", "rights", "relatedItems",
                     "reviewAuthorLastname", "reviewAuthorFirstname"]

    for field in hidden_fields:
        schema[field].widget.condition = 'python:False'

    schemata.marshall_register(schema)
Пример #25
0
from recensio.contenttypes.content import container

from recensio.contenttypes import contenttypesMessageFactory as _

from recensio.contenttypes.interfaces import IVolume
from recensio.contenttypes.config import PROJECTNAME

DoiSettingsSchema = atapi.Schema((

    atapi.BooleanField(
        'doiRegistrationActive',
        accessor='isDoiRegistrationActive',
        storage=atapi.AnnotationStorage(),
        default=True,
        widget=atapi.BooleanWidget(
            label=_(u"Activate DOI registration"),
            description=_(
                u'description_activate_doi_registration',
                default=(u"Activates the registration of DOIs at da|ra"),
            ),
        ),
    ),

))

VolumeSchema = folder.ATFolderSchema.copy() + DoiSettingsSchema.copy() + atapi.Schema((

    atapi.StringField(
        'yearOfPublication',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(