Exemplo n.º 1
0
class IPdfFile(model.Schema):
    """ Marker interfce and Dexterity Python Schema for Promotion
    """
    # directives.omitted('title')
    title = schema.TextLine(
        title=_(u'Title'),
        # description=u"",
        required=False,
        defaultFactory=request_title,
    )

    description = schema.Text(
        title=_(u'Description'),
        # description=u"",
        required=False)

    file = namedfile.NamedBlobFile(
        title=_(u'File'),
        required=True,
        constraint=isValidFileType,
        # primary=True,
    )
    model.primary('file')

    directives.omitted('thumbfile')
    thumbfile = namedfile.NamedBlobImage(
        title=_(u'ImageThumb'),
        required=False,
    )
Exemplo n.º 2
0
class IPersonalData(model.Schema):

    # directives.order_before(title='evaluation_date')
    classification = schema.Choice(
        title=_(u'Classification'),
        vocabulary='collective.judgment.ClassificationsVocabulary',
        required=True)

    directives.omitted('title')
    title = schema.TextLine(title=u'Title', required=False)

    first_name = schema.TextLine(
        title=_(u'First Name'),
        required=True,
    )

    last_name = schema.TextLine(
        title=_(u'Last Name'),
        required=True,
    )

    current_position = schema.Choice(
        title=_(u'Current Position'),
        vocabulary='collective.judgment.PositionsVocabulary',
        required=True)
Exemplo n.º 3
0
def YesorNoVocabulary(context):
    items = [
        (_(u'No'), 'no'),
        (_(u'Yes'), 'yes'),
    ]

    items = [SimpleTerm(i[1], i[1], i[0]) for i in items]
    return SimpleVocabulary(items)
Exemplo n.º 4
0
def ClassificationsVocabulary(context):
    items = [
        (_(u'Researcher'), 'researcher'),
        (_(u'Academic Technician'), 'academictec'),
    ]

    items = [SimpleTerm(i[1], i[1], i[0]) for i in items]
    return SimpleVocabulary(items)
Exemplo n.º 5
0
class ITenure(model.Schema):
    """ Marker interfce and Dexterity Python Schema for Tenure
    """

    directives.order_after(evaluation_date='IPersonalData.current_position')
    evaluation_date = schema.Date(
        title=_(u'Evaluation deadline'),
        required=True,
    )

    @invariant
    def validate_dates(data):
        try:
            really_creation_date = data.__context__.creation_date
            creation_date = datetime.datetime(really_creation_date.year(),
                                              really_creation_date.month(),
                                              really_creation_date.day(),
                                              really_creation_date.hour(),
                                              really_creation_date.minute())
        except Exception:
            creation_date = datetime.datetime.today()

        if (data.evaluation_date < creation_date.date()):
            raise Invalid(
                _('label_error_dates',
                  default=
                  u'The Evaluation deadline must be grather than Creation Date'
                  ))
Exemplo n.º 6
0
def isValidFileType(value):

    if value:
        if value.contentType != 'application/pdf':
            raise Invalid(_(u'Invalid Type File: please correct it, only accept pdf file'))

    return True
Exemplo n.º 7
0
    def validate_orderpositions(data):
        pvalue = {
            'IAC': 1,
            'ITA': 2,
            'ITB': 3,
            'ITC': 4,
            'TAAA': 5,
            'TAAB': 6,
            'TAAC': 7,
            'TATA': 8,
            'TATB': 9,
            'TATC': 10,
        }
        rposition = pvalue.get(data.requestedposition, 0)

        try:
            apositionvalue = data.__context__.REQUEST.form.get('form.widgets.IPersonalData.current_position', '')
        except Exception:
            apositionvalue = ''

        aposition = 0
        if apositionvalue:
            aposition = pvalue.get(data.__context__.REQUEST.form['form.widgets.IPersonalData.current_position'][0], 0)
        if aposition >= rposition:
            raise Invalid(
                _('label_error_orderpositions',
                  default=u'The Requested Position must be grather than Position')
            )
Exemplo n.º 8
0
    def validate_dates(data):
        try:
            really_creation_date = data.__context__.creation_date
            creation_date = datetime.datetime(really_creation_date.year(),
                                              really_creation_date.month(),
                                              really_creation_date.day(),
                                              really_creation_date.hour(),
                                              really_creation_date.minute())
        except Exception:
            creation_date = datetime.datetime.today()

        if (data.evaluation_date < creation_date.date()):
            raise Invalid(
                _('label_error_dates',
                  default=
                  u'The Evaluation deadline must be grather than Creation Date'
                  ))
Exemplo n.º 9
0
    def send_email(self):
        catalog = api.portal.get_tool(name='portal_catalog')
        brains = catalog(path=dict(query='/'.join(
            self.context.getPhysicalPath()),
                                   depth=1),
                         review_state='pending',
                         sort_on='evaluation_date')

        evaluators = api.user.get_users(groupname='evaluators')
        emails = {}

        for brain in brains:
            values = IEvaluation(brain.getObject()).evaluations
            for gmember in evaluators:
                if values.get(gmember.id, None) is None:
                    emails.setdefault(gmember.id, [])
                    emails[gmember.id].append((brain.Title, brain.getURL()))

        evaluators_data = {}
        for evaluator in evaluators:
            evaluators_data[evaluator.id] = {
                'name': evaluator.getProperty('fullname'),
                'email': evaluator.getProperty('email'),
            }

        message = []
        for k, v in emails.iteritems():
            salutation = _(
                u'email_intro_msg',
                default=u'Dear ${name}',
                mapping={u'name': safe_unicode(evaluators_data[k]['name'])})
            if len(v) > 1:
                mail_intro = _(u'You have the following pending reviews:')
            else:
                mail_intro = _(u'you have the following pending review:')
            mail_cases = u'\n'.join(
                [i[0] + u' ' + safe_unicode(i[1]) for i in v])
            mail_sign = u'Asuntos Académicos\nInstituto de Matemáticas, UNAM'
            salutation = self.context.translate(salutation)
            mail_intro = self.context.translate(mail_intro)
            mail_text = '\n'.join([
                salutation, mail_intro, u'\n', mail_cases, u'\n\n', mail_sign
            ])
            mail_subject = self.context.translate(
                _(u'Pending reviews, IM UNAM'))
            try:
                api.portal.send_email(
                    recipient=evaluators_data[k]['email'],
                    sender='*****@*****.**',
                    subject=mail_subject,
                    body=mail_text,
                )
                message.append(evaluators_data[k]['email'])
            except SMTPRecipientsRefused:
                # Don't disclose email address on failure
                raise SMTPRecipientsRefused(
                    'Recipient address rejected by server')

        IStatusMessage(self.request).addStatusMessage(
            self.context.translate(_(u'The system sended email to: ')) +
            ', '.join(message), 'info')
        return True
Exemplo n.º 10
0
class IPromotion(model.Schema):
    """ Marker interfce and Dexterity Python Schema for Promotion
    """

    # directives.widget(level=RadioFieldWidget)
    directives.order_after(requestedposition='IPersonalData.current_position')
    requestedposition = schema.Choice(
        title=_(u'Requested position'),
        vocabulary='collective.judgment.PositionsVocabulary',
        required=True
    )
    directives.order_after(evaluation_date='requestedposition')
    evaluation_date = schema.Date(
        title=_(u'Evaluation deadline'),
        required=True,
    )

    @invariant
    def validate_dates(data):
        try:
            really_creation_date = data.__context__.creation_date
            creation_date = datetime.datetime(
                really_creation_date.year(),
                really_creation_date.month(),
                really_creation_date.day(),
                really_creation_date.hour(),
                really_creation_date.minute()
            )
        except Exception:
            creation_date = datetime.datetime.today()

        if (data.evaluation_date < creation_date.date()):
            raise Invalid(
                _('label_error_dates',
                  default=u'The Evaluation deadline must be grather than Creation Date')
            )

    @invariant
    def validate_orderpositions(data):
        pvalue = {
            'IAC': 1,
            'ITA': 2,
            'ITB': 3,
            'ITC': 4,
            'TAAA': 5,
            'TAAB': 6,
            'TAAC': 7,
            'TATA': 8,
            'TATB': 9,
            'TATC': 10,
        }
        rposition = pvalue.get(data.requestedposition, 0)

        try:
            apositionvalue = data.__context__.REQUEST.form.get('form.widgets.IPersonalData.current_position', '')
        except Exception:
            apositionvalue = ''

        aposition = 0
        if apositionvalue:
            aposition = pvalue.get(data.__context__.REQUEST.form['form.widgets.IPersonalData.current_position'][0], 0)
        if aposition >= rposition:
            raise Invalid(
                _('label_error_orderpositions',
                  default=u'The Requested Position must be grather than Position')
            )