예제 #1
0
 def __call__(self, context):
     languages = []
     languages.append(SimpleVocabulary.createTerm(u'CA', 'CA', _(u'CA')))
     languages.append(SimpleVocabulary.createTerm(u'ES', 'ES', _(u'ES')))
     languages.append(SimpleVocabulary.createTerm(u'EN', 'EN', _(u'EN')))
     languages.append(SimpleVocabulary.createTerm(u'FR', 'FR', _(u'FR')))
     return SimpleVocabulary(languages)
예제 #2
0
class IPublicationOffer(model.Schema):

    form.widget('fieldset_opt', FieldsetFieldWidget)
    fieldset_opt = schema.Text(
        default=_(u'Dates'),
        required=False,
    )

    effective = schema.Datetime(
        title=_PMF(u'label_effective_date', u'Publishing Date'),
        description=_(
            u'help_effective_date',
            default=u"The date the item will be published."),
        required=False
    )

    expired = schema.Datetime(
        title=_PMF(u'label_expiration_date', u'Expiration Date'),
        description=_(
            u'help_expiration_date',
            default=u"The date that the item will expire."),
        required=False,
        defaultFactory=expiresDefaultValue,
    )

    form.omitted('effective')
    form.no_omit(IEditForm, 'expired')
    form.no_omit(IAddForm, 'expired')
예제 #3
0
 def __call__(self, context):
     types = []
     types.append(
         SimpleVocabulary.createTerm(u'Universitat', 'Universitat',
                                     _(u'Universitat')))
     types.append(
         SimpleVocabulary.createTerm(u'Empresa', 'Empresa', _(u'Empresa')))
     return SimpleVocabulary(types)
예제 #4
0
 def getModalities(self):
     return [{
         'id': 'c',
         'lit': _(u"Company")
     }, {
         'id': 'u',
         'lit': _(u"University")
     }]
예제 #5
0
class IIdentitatDigitalSettings(model.Schema):
    """ Global Identitat Digital TFE Market settings. This describes records stored in the
    configuration registry and obtainable via plone.registry.
    """
    identitat_url = schema.TextLine(
        title=_(u'URL'),
        description=_(u'URL to access the digital identity'),
        required=True)

    identitat_apikey = schema.Password(title=_(u'APIKEY'), required=True)
예제 #6
0
 def getDates(self):
     return [{
         'id': 'a',
         'lit': _(u"All")
     }, {
         'id': 'w',
         'lit': _(u"Last week")
     }, {
         'id': 'm',
         'lit': _(u"Last month")
     }]
예제 #7
0
 def __call__(self, context):
     types = []
     types.append(
         SimpleVocabulary.createTerm(u'Study', 'Study', _(u'Study')))
     types.append(
         SimpleVocabulary.createTerm(u'Project', 'Project', _(u'Project')))
     types.append(
         SimpleVocabulary.createTerm(u'Design', 'Design', _(u'Design')))
     types.append(
         SimpleVocabulary.createTerm(u'Others', 'Others', _(u'Others')))
     return SimpleVocabulary(types)
예제 #8
0
    def update(self):
        if 'submit' in self.request.form:
            pc = api.portal.get_tool('portal_catalog')
            offer = pc.searchResults({'portal_type': 'genweb.tfemarket.offer',
                                      'UID': self.request.form['offer']})
            if len(offer) > 0:
                offer = offer[0].getObject()
                market = offer.getParentNode()
                try:
                    data = {
                        'title': 'Copy of ' + offer.title,
                        'description': offer.description,
                        'topic': offer.topic,
                        'offer_type': offer.offer_type if 'offer_type' in offer else _(u'Project'),
                        'degree': offer.degree,
                        'keys': offer.keys,
                        'teacher_manager': offer.teacher_manager,
                        'teacher_fullname': offer.teacher_fullname,
                        'teacher_email': offer.teacher_email,
                        'dept': offer.dept,
                        'type_codirector': offer.type_codirector,
                        'codirector_id': offer.codirector_id,
                        'codirector': offer.codirector,
                        'codirector_email': offer.codirector_email,
                        'codirector_dept': offer.codirector_dept,
                        'num_students': offer.num_students,
                        'workload': offer.workload,
                        'targets': offer.targets,
                        'features': offer.features,
                        'requirements': offer.requirements,
                        'lang': offer.lang,
                        'modality': offer.modality,
                        'company': offer.company,
                        'grant': offer.grant,
                        'confidential': offer.confidential,
                        'environmental_theme': offer.environmental_theme,
                        'scope_cooperation': offer.scope_cooperation,
                        'tfgm': offer.tfgm,
                    }
                    copyOffer = createContentInContainer(market, "genweb.tfemarket.offer", **data)
                    copyOffer.setEffectiveDate(offer.effective_date)
                    copyOffer.setExpirationDate(offer.expiration_date)
                    copyOffer.reindexObject()

                    IStatusMessage(self.request).addStatusMessage(_(u"The offer has been copied."), 'info')
                    self.request.response.redirect(self.context.absolute_url() + "/@@tfemarket-utils-rename-offer?offer=" + copyOffer.UID())
                except:
                    IStatusMessage(self.request).addStatusMessage(_(u"The offer could not be copied."), 'error')
            else:
                IStatusMessage(self.request).addStatusMessage(_(u"The offer could not be copied."), 'error')
예제 #9
0
 def update(self):
     if 'submit' in self.request.form:
         pc = api.portal.get_tool('portal_catalog')
         offer = pc.searchResults({'portal_type': 'genweb.tfemarket.offer',
                                   'UID': self.request.form['offer']})
         if len(offer) > 0:
             offer = offer[0]
             parent = offer.getObject().aq_parent
             try:
                 parent.manage_delObjects([offer.id])
                 IStatusMessage(self.request).addStatusMessage(_(u"The offer has been removed."), 'info')
             except:
                 IStatusMessage(self.request).addStatusMessage(_(u"The offer could not be removed."), 'error')
         else:
             IStatusMessage(self.request).addStatusMessage(_(u"The offer could not be removed."), 'error')
예제 #10
0
def getDegrees(context):
    titulacions = []
    result = getCookie()
    if result:
        degrees = result['degrees']

        for item in degrees:
            titulacions.append(
                SimpleTerm(value=item['degree_id'],
                           title=item['degree_title']))
        return SimpleVocabulary(titulacions)
    else:
        if getattr(context, 'degree_id', False):
            if context.degree_id:
                titulacions.append(
                    SimpleTerm(value=context.degree_id,
                               title=context.degree_title))
                return SimpleVocabulary(titulacions)
            else:
                context.plone_utils.addPortalMessage(
                    _(u"Comprova que la teva titulació correspon a la titulació per a la qual s'oferta el treball"
                      ), 'error')
        else:
            titulacions.append(SimpleTerm(value='None', title=''))
            return SimpleVocabulary(titulacions)
예제 #11
0
 def updateWidgets(self):
     super(Add, self).updateWidgets()
     if not checkPermissionCreateApplications(self, self.context, False):
         self.context.plone_utils.addPortalMessage(
             _(u"You have already created an application. You can see it on the main page of the market."
               ), 'error')
         self.redirect(self.context.absolute_url())
예제 #12
0
 def __call__(self, context):
     types = []
     types.append(SimpleVocabulary.createTerm(u'UPC', 'UPC', u'UPC'))
     types.append(
         SimpleVocabulary.createTerm(u'External', 'External',
                                     _(u'External')))
     return SimpleVocabulary(types)
예제 #13
0
def getDegreeLiteralFromId(id):
    degrees = getDegrees()
    degree = _(u'Degree deleted')
    result = [item['lit'] for item in degrees if item['id'] == id]
    if result:
        degree = result[0]
    return degree
예제 #14
0
 def getTypes(self):
     return [{
         'id': 'a',
         'lit': _(u"MAll")
     }, {
         'id': 'Study',
         'lit': _(u"Study")
     }, {
         'id': 'Project',
         'lit': _(u"Project")
     }, {
         'id': 'Design',
         'lit': _(u"Design")
     }, {
         'id': 'Others',
         'lit': _(u"Others")
     }]
예제 #15
0
    def render(self):
        try:
            from plone.protect.interfaces import IDisableCSRFProtection
            alsoProvides(self.request, IDisableCSRFProtection)
        except:
            pass

        estat = self.request.form.get('estat')
        itemid = self.request.form.get('id')

        try:
            portal = api.portal.get()
            currentItem = portal.unrestrictedTraverse(itemid)
            isCreator = api.user.get_current().id in currentItem.creators
            if currentItem and (isTeachersOffer(currentItem.getParentNode()) or isCreator):
                if currentItem.portal_type == 'genweb.tfemarket.offer':
                    if estat in ['assign', 'assignalofertaintranet']:
                        if not checkOfferhasAssign(currentItem):
                            self.context.plone_utils.addPortalMessage(_(u"The offer can't be assign. There must be at least one confirmed application and the others cancelled, rejected or renounced"), 'error')
                            redirectToMarket(self)
                            return None

                    wf_tool = getToolByName(self.context, 'portal_workflow')
                    tools = getMultiAdapter((self.context, self.request), name='plone_tools')
                    market = currentItem.getParentNode()
                    marketWorkflow = tools.workflow().getWorkflowsFor(market)[0]
                    marketStatus = wf_tool.getStatusOf(marketWorkflow.id, market)
                    marketState = marketWorkflow['states'][marketStatus['review_state']]

                    if (marketState.id == 'published' and estat == 'publicaalintranet') or (marketState.id == 'intranet' and estat == 'publicaloferta'):
                        self.context.plone_utils.addPortalMessage(_(u'Error you can\'t perform the action.'), 'error')
                        redirectToMarket(self)
                        return None

                wftool = getToolByName(self.context, 'portal_workflow')
                wftool.doActionFor(currentItem, estat)
                redirectToMarket(self)
            else:
                self.context.plone_utils.addPortalMessage(_(u'Error you can\'t perform the action.'), 'error')
                redirectToMarket(self)
        except BusError as err:
            self.context.plone_utils.addPortalMessage(err.value['resultat'], 'error')
            redirectToMarket(self)
        except:
            self.context.plone_utils.addPortalMessage(_(u'Error you can\'t perform the action.'), 'error')
            redirectToMarket(self)
예제 #16
0
def offerDeleted(offer, event):
    """ Checks if can deleted genweb.tfemarket.offer.
    """

    if checkOfferhasValidApplications(offer):
        offer.plone_utils.addPortalMessage(_(u"The offer can't be deleted."),
                                           'error')
        request = getRequest()
        request.response.redirect(offer.absolute_url())
예제 #17
0
 def getTFGM(self):
     return [{
         'id': 'a',
         'lit': _(u"MAll")
     }, {
         'id': 'TFG',
         'lit': u"TFG"
     }, {
         'id': 'TFM',
         'lit': u"TFM"
     }]
예제 #18
0
    def update(self):
        if 'submit' in self.request.form:
            pc = api.portal.get_tool('portal_catalog')
            offer = pc.searchResults({'portal_type': 'genweb.tfemarket.offer',
                                      'UID': self.request.form['offer']})
            if len(offer) > 0:
                offer = offer[0].getObject()
                offer.title = self.request.form['newTitle']
                parent = offer.getParentNode()
                try:
                    parent.manage_renameObject(offer.id, self.request.form['newShortname'])
                    offer.reindexObject()

                    for application in getApplicationsFromContent(offer):
                        application.offer_title = self.request.form['newTitle']
                        application.reindexObject()
                    IStatusMessage(self.request).addStatusMessage(_(u"The offer has been modified."), 'info')
                except:
                    IStatusMessage(self.request).addStatusMessage(_(u"Error the identifier exists."), 'error')
            else:
                IStatusMessage(self.request).addStatusMessage(_(u"Error the identifier exists."), 'error')
예제 #19
0
def offerCanceled(offer, event):
    """ If genweb.tfemarket.offer change WF, checks if can be canceled.
    """

    if event.transition is not None:
        if event.transition.id == 'cancellaloferta':
            if checkOfferhasValidApplications(offer):
                offer.plone_utils.addPortalMessage(
                    _(u"The offer can't be canceled if it contains active applications."
                      ), 'info')
                request = getRequest()
                request.response.redirect(offer.absolute_url())
예제 #20
0
def checkPermissionCreateApplications(self, context, errors=False):
    roles = api.user.get_roles()

    if 'TFE Manager' in roles or 'TFE Teacher' in roles:
        if errors:
            self.context.plone_utils.addPortalMessage(
                _(u"You don't have permission for create a application."),
                'error')
        return False

    wf_tool = getToolByName(context, 'portal_workflow')
    offer_workflow = wf_tool.getWorkflowsFor(context)[0].id
    offer_status = wf_tool.getStatusOf(offer_workflow, context)

    if 'Anonymous' in roles and offer_status['review_state'] == 'public':
        return True

    return checkPermissionCreateObject(self, context,
                                       'genweb.tfemarket.application')
예제 #21
0
def getDegrees():
    registry = queryUtility(IRegistry)
    tfe_tool = registry.forInterface(ITfemarketSettings)
    current_language = api.portal.get_current_language()

    result = []
    if tfe_tool.titulacions_table:
        for item in tfe_tool.titulacions_table:
            titulacio = str(item['plan_year']) + " - "
            if current_language == 'ca':
                titulacio += item['titulacio_ca']
            elif current_language == 'es':
                titulacio += item['titulacio_es']
            else:
                titulacio += item['titulacio_en']

            result.append({'id': item['codi_mec'], 'lit': titulacio})

    result = sorted(result, key=itemgetter('lit'))
    result.insert(0, {'id': 'a', 'lit': _(u"All")})
    return result
예제 #22
0
class IBUSSOASettings(model.Schema):
    """ Global BUS SOA TFE Market settings. This describes records stored in the
    configuration registry and obtainable via plone.registry.
    """
    # BUS SOA

    bus_url = schema.TextLine(title=_(u'URL'),
                              description=_(u'URL to access the bus'),
                              required=False)

    bus_user = schema.TextLine(title=_(u'User'),
                               description=_('User to connect to the bus'),
                               required=False)

    bus_password = schema.Password(title=_(u'Password'), required=False)

    bus_apikey = schema.Password(title=_(u'APIKEY'), required=False)
예제 #23
0
def getStudentData(self, item, user):

    if not checkPermissionCreateApplications(self, item, True):
        return None

    result = getTokenIdentitatDigital()
    if result.status_code == 201:
        token = json.loads(result.content)['tokenAcl']

        result = getDadesEst(self, user, token)
        if result.status_code == 200:
            est = json.loads(result.content)
            est_colectius = est['uePerfil']

            for col in est_colectius:
                if col['perfilId'] in ['EST', 'ESTMASTER']:
                    student_data = {
                        'offer_id': item.offer_id,
                        'offer_title': item.title,
                        'dni': str(est['document']),
                        'email': str(est['emailPreferent']),
                        'idPrisma': str(col['idOrigen']),
                        'degrees': []
                    }

                    if 'cognom2' in est:
                        fullname = str(est['nom']) + ' ' + str(
                            est['cognom1']) + ' ' + str(est['cognom2'])
                        student_data.update({'fullname': fullname})

                    else:
                        fullname = str(est['nom']) + ' ' + str(est['cognom1'])
                        student_data.update({'fullname': fullname})

                    id_prisma = student_data['idPrisma']
                    numDocument = student_data['dni']

                    registry = queryUtility(IRegistry)
                    bussoa_tool = registry.forInterface(IBUSSOASettings)
                    tfe_tool = registry.forInterface(ITfemarketSettings)
                    bussoa_url = bussoa_tool.bus_url
                    bussoa_user = bussoa_tool.bus_user
                    bussoa_pass = bussoa_tool.bus_password
                    bussoa_apikey = bussoa_tool.bus_apikey
                    tipus_alta = tfe_tool.enroll_type

                    res_data = requests.get(
                        bussoa_url + "/%s" % id_prisma + '?tipusAltaTFE=' +
                        "%s" % tipus_alta + '&numDocument=' +
                        "%s" % numDocument,
                        headers={'apikey': bussoa_apikey},
                        auth=(bussoa_user, bussoa_pass))

                    data = res_data.json()
                    if res_data.ok:

                        llistat_expedients = data['llistatExpedients']

                        catalog = api.portal.get_tool(name='portal_catalog')
                        from genweb.tfemarket.content.application import IApplication
                        items = catalog(
                            object_provides=IApplication.__identifier__,
                            Creator=api.user.get_current().id)

                        llistat_solicituds_actives_usuari = []
                        for useritem in items:
                            if useritem.review_state not in [
                                    'cancelled', 'rejected', 'renounced'
                            ]:
                                llistat_solicituds_actives_usuari.append(
                                    useritem.getObject().degree_id)

                        for expedient in llistat_expedients:

                            if expedient[
                                    'codiMecPrograma'] in item.degree and expedient[
                                        'codiMecPrograma'] not in llistat_solicituds_actives_usuari:
                                student_data['degrees'].append({
                                    'degree_id':
                                    expedient['codiMecPrograma'],
                                    'degree_title':
                                    getDegreeLiteralFromId(
                                        expedient['codiMecPrograma']),
                                    'codi_expedient':
                                    expedient['codiExpedient']
                                })

                                return student_data

                        self.context.plone_utils.addPortalMessage(
                            _(u"El treball que vols sol·licitar no està ofertat per a la titulació que curses o ja has sol·licitat una amb aquesta mateixa titulació. Contacta amb la secretaria del teu centre."
                              ), 'error')
                        return None
                    else:
                        reason = data['resultat']
                        self.context.plone_utils.addPortalMessage(
                            _(u"PRISMA: %s" % reason), 'error')
                        return None

            self.context.plone_utils.addPortalMessage(
                _(u"VINCULACIÓ: No hem trobat la teva vinculació com a d'ESTUDIANT. Contacta amb la teva secretaria."
                  ), 'error')
            return None
        else:
            self.context.plone_utils.addPortalMessage(
                _(u"DIRECTORI: Usuari no trobat en al directori"), 'error')
            return None
    else:
        self.context.plone_utils.addPortalMessage(
            _(u"IDENTITAT DIGITAL: %s" % result.status_code), 'error')
        return None
예제 #24
0
class ITfemarketSettings(model.Schema):
    """ Global TFE Market settings. This describes records stored in the
    configuration registry and obtainable via plone.registry.
    """

    model.fieldset(
        'Settings',
        _(u'Settings'),
        fields=['center_code', 'center_name', 'review_state', 'enroll_type'],
    )

    model.fieldset(
        'Titulacions',
        _(u'Titulacions'),
        fields=['titulacions_table'],
    )

    model.fieldset('Ofertes',
                   _(u'Ofertes'),
                   fields=[
                       'life_period', 'view_num_students', 'import_offers',
                       'count_offers'
                   ])

    model.fieldset(
        'TopicTFE',
        _(u'classifications'),
        fields=['topics', 'tags', 'languages'],
    )

    # SETTINGS

    center_code = schema.Int(title=_(u'Center code'),
                             required=False,
                             description=_(u'Center code'))

    center_name = schema.TextLine(
        title=_(u"Name center"),
        required=False,
    )

    review_state = schema.Bool(
        title=_(u"Review State"),
        default=False,
        description=_(u'Select if you want to add "Reviewer" role'),
        required=False,
    )

    enroll_type = schema.Choice(
        title=_(u'Enroll type '),
        description=_('Parameter to post the student enroll'),
        vocabulary=u"genweb.tfemarket.Enrolls",
        default=u'I',
        required=True)

    # CLASSIFICATIONS

    topics = schema.Text(
        title=_(u"Topics of the TFE"),
        description=_(u'Add topics one per line'),
        required=False,
    )

    tags = schema.Text(
        title=_(u"Tags"),
        description=_(u'Add tags one per line'),
        required=False,
    )

    form.widget(languages=CheckBoxFieldWidget)
    languages = schema.List(
        title=_(u"Development languages"),
        description=_(u'Add languages one per line'),
        value_type=schema.Choice(source=u"genweb.tfemarket.AllLanguages"),
        required=False,
    )

    # TITULACIONS

    form.widget(titulacions_table=DataGridFieldFactory)
    titulacions_table = schema.List(
        title=_(u'Titulacions'),
        description=_(u'help_titulacions_table',
                      default=u'Imported dades from csv'),
        value_type=DictRow(title=_(u'titulacionstable'),
                           schema=ITableTitulacions),
        required=False)

    # OFERTES

    life_period = schema.Int(
        title=_(u'Months until expiration'),
        description=_('Months until the offer expires automatically'),
        required=True,
        default=12,
    )

    view_num_students = schema.Bool(
        title=_(u'View number of students'),
        description=
        _('Uncheck this option if you do not want to see the number of students in an offer'
          ),
        required=False,
        default=True,
    )

    directives.mode(import_offers="display")
    import_offers = schema.Text(
        title=_(u"Import offers"),
        description=
        _(u'To import the offers access the following <a href=\"import_ofertes\">link</a>.'
          ),
        required=False,
    )

    directives.mode(count_offers="display")
    count_offers = schema.Int(
        title=_(u"Number of offers created"),
        description=
        _(u'To reset the counter access the following <a href=\"reset_offers_counter\">link</a>.'
          ),
        required=False,
        default=0,
    )
예제 #25
0
 def __call__(self, context):
     types = []
     types.append(SimpleVocabulary.createTerm(u'I', 'I', _(u'Enroll')))
     types.append(SimpleVocabulary.createTerm(u'R', 'R', _(u'Register')))
     return SimpleVocabulary(types)
예제 #26
0
class IdentitatDigitalSettingsEditForm(controlpanel.RegistryEditForm):

    schema = IIdentitatDigitalSettings
    label = _(u'Identitat Digital TFE')
예제 #27
0
class IApplication(form.Schema):
    """ Application for an offer
    """
    form.mode(degree_title='hidden')
    degree_title = schema.TextLine(
        title=_(u'Title of the degree with which you request the offer'),
        required=False,
    )

    form.mode(IEditForm, degree_id='display')
    degree_id = schema.Choice(
        title=_(u'Title of the degree with which you request the offer'),
        source=getDegrees,
        required=True,
    )

    form.widget('offer_id', ReadOnlyInputFieldWidget)
    offer_id = schema.TextLine(
        title=_(u'Offer id'),
        required=True,
    )

    form.widget('offer_title', ReadOnlyInputFieldWidget)
    offer_title = schema.TextLine(
        title=_(u'Offer title'),
        required=True,
    )

    form.widget('dni', ReadOnlyInputFieldWidget)
    dni = schema.TextLine(
        title=_(u'DNI'),
        required=True,
    )

    form.widget('title', StudentInputFieldWidget)
    title = schema.TextLine(
        title=_(u'Fullname'),
        required=True,
    )

    phone = schema.TextLine(
        title=_(u"Telephone"),
        required=False,
    )

    form.widget('email', ReadOnlyInputFieldWidget)
    email = schema.TextLine(
        title=_(u'Email'),
        required=True,
    )

    form.mode(prisma_id='hidden')
    prisma_id = schema.TextLine(
        title=_(u'PRISMA id'),
        required=False,
    )

    form.mode(codi_expedient='hidden')
    codi_expedient = schema.TextLine(
        title=_(u'Codi Expedient'),
        required=False,
    )

    body = schema.Text(
        title=_(u'Body'),
        required=False,
    )
예제 #28
0
class BUSSOASettingsEditForm(controlpanel.RegistryEditForm):

    schema = IBUSSOASettings
    label = _(u'BUS SOA TFE')
예제 #29
0
class TfemarketSettingsEditForm(controlpanel.RegistryEditForm):

    schema = ITfemarketSettings
    label = _(u'UPC Mercat TFE')
예제 #30
0
class ITableTitulacions(form.Schema):

    codi_prisma = schema.TextLine(title=_(u'PRISMA code'),
                                  required=False,
                                  description=_(u'Degree code at PRISMA'))

    progam_type = schema.TextLine(title=_(u'Program type'), required=False)

    codi_mec = schema.TextLine(title=_(u'MEC code'),
                               required=False,
                               description=_(u'MEC degree code'))

    plan_year = schema.TextLine(
        title=_(u'Plan year'),
        required=False,
    )

    titulacio_es = schema.TextLine(title=_(u'Titulacions ES'),
                                   description=_(u''),
                                   required=False)

    titulacio_ca = schema.TextLine(title=_(u'Titulacions CA'),
                                   description=_(u''),
                                   required=False)

    titulacio_en = schema.TextLine(title=_(u'Titulacions EN'),
                                   description=_(u''),
                                   required=False)