module.py 3.11 KB
Newer Older
1 2 3 4
# -*- coding: utf-8 -*-

# Copyright(C) 2013      Bezleputh
#
5
# This file is part of a weboob module.
6
#
7
# This weboob module is free software: you can redistribute it and/or modify
8 9 10 11
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
12
# This weboob module is distributed in the hope that it will be useful,
13 14 15 16 17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
18
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
19

ntome's avatar
ntome committed
20
from collections import OrderedDict
21

22
from weboob.tools.backend import Module, BackendConfig
23
from weboob.capabilities.job import CapJob, BaseJobAdvert
24 25 26 27
from weboob.tools.value import Value

from .browser import MonsterBrowser

Florent Fourcot's avatar
Florent Fourcot committed
28
__all__ = ['MonsterModule']
29 30


31
class MonsterModule(Module, CapJob):
32 33 34 35 36
    NAME = 'monster'
    DESCRIPTION = u'monster website'
    MAINTAINER = u'Bezleputh'
    EMAIL = 'carton_ben@yahoo.fr'
    LICENSE = 'AGPLv3+'
Romain Bignon's avatar
Romain Bignon committed
37
    VERSION = '1.6'
38 39 40 41

    BROWSER = MonsterBrowser

    type_contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
Bezleputh's avatar
Bezleputh committed
42 43 44 45 46 47 48 49
        'Interim-ou-CDD-ou-mission_8': u'Interim ou CDD ou mission',
        'CDI_8': u'CDI',
        'Stage-Apprentissage-Alternance_8': u'Stage/Apprentissage/Alternance',
        ' ': u'Autres',
        'Indépendant-Freelance-Saisonnier-Franchise_8': u'Indépendant/Freelance/Saisonnier/Franchise',
        'Journalier_8': u'Journalier',
        'Temps-Partiel_8': u'Temps Partiel',
        'Temps-Plein_8': u'Temps Plein',
50
    }.items())])
51 52 53 54 55 56 57 58 59

    date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
        '-1': u'N importe quelle date',
        '000000': u'Aujourd hui',
        '1': u'2 derniers jours',
        '3': u'3 derniers jours',
        '7': u'Les 7 derniers jours',
        '14': u'Les 14 derniers jours',
        '30': u'30 derniers jours',
60
    }.items())])
61 62 63 64

    CONFIG = BackendConfig(
        Value('job_name', label='Job name', masked=False, default=''),
        Value('place', label='Place', masked=False, default=''),
Bezleputh's avatar
Bezleputh committed
65
        Value('contract', label=u'Contract', choices=type_contrat_choices, default=''),
66 67 68 69
        Value('limit_date', label=u'Date', choices=date_choices, default='-1'),
    )

    def search_job(self, pattern=None):
70
        return self.browser.search_job(pattern)
71 72

    def advanced_search_job(self):
73 74 75 76
        return self.browser.advanced_search_job(job_name=self.config['job_name'].get(),
                                                place=self.config['place'].get(),
                                                contract=self.config['contract'].get(),
                                                limit_date=self.config['limit_date'].get())
77 78

    def get_job_advert(self, _id, advert=None):
79
        return self.browser.get_job_advert(_id, advert)
80 81

    def fill_obj(self, advert, fields):
82
        return self.get_job_advert(advert.id, advert)
83

84
    OBJECTS = {BaseJobAdvert: fill_obj}