| 1 | # -*- encoding: utf-8 -* |
| 2 | from django.shortcuts import render_to_response, redirect, get_object_or_404 |
| 3 | |
| 4 | from django.utils import simplejson |
| 5 | from auf.django.emploi import models as emploi |
| 6 | from auf.django.emploi import forms as emploiForms |
| 7 | from restkit import request as req |
| 8 | |
| 9 | class API: |
| 10 | def __init__(self, request): |
| 11 | self.request = request |
| 12 | |
| 13 | def offre_emploi_liste(self): |
| 14 | url = "http://127.0.0.1:8080/api/offre_emploi_liste/" |
| 15 | r = req(url) |
| 16 | liste_json = r.body_string() |
| 17 | liste_offres = simplejson.loads(liste_json) |
| 18 | obj_offres_emploi = [] |
| 19 | |
| 20 | for offre_dict in liste_offres: |
| 21 | offre = emploi.OffreEmploi() |
| 22 | #offre.est_affiche = offre_dict['est_affiche'] |
| 23 | #offre.statut = offre_dict['statut'] |
| 24 | offre.nom = offre_dict['nom'] |
| 25 | offre.resume = offre_dict['resume'] |
| 26 | offre.description = offre_dict['description'] |
| 27 | #offre.poste = offre_dict['poste'] |
| 28 | offre.date_limite = offre_dict['date_limite'] |
| 29 | #offre.region = offre_dict['region'] |
| 30 | #offre.bureau = offre_dict['bureau'] |
| 31 | offre.duree_affectation = offre_dict['duree_affectation'] |
| 32 | offre.renumeration = offre_dict['renumeration'] |
| 33 | offre.debut_affectation = offre_dict['debut_affectation'] |
| 34 | #offre.lieu_affectation = offre_dict['lieu_affectation'] |
| 35 | obj_offres_emploi.append(offre) |
| 36 | return obj_offres_emploi |
| 37 | |
| 38 | def offre_emploi(self, offre_id): |
| 39 | url = "/call/offre_emploi/%s" |
| 40 | r = req(url % (offre_id)) |
| 41 | offre_json = r.body_string() |
| 42 | offre_dict = simplejson.loads(offre_json) |
| 43 | |
| 44 | obj_offre = emploi.OffreEmploi() |
| 45 | obj_offre.est_affiche = offre_dict('est_affiche') |
| 46 | obj_offre.statut = offre_dict('statut') |
| 47 | obj_offre.nom = offre_dict('nom') |
| 48 | obj_offre.resume = offre_dict('resume') |
| 49 | obj_offre.description = offre_dict('description') |
| 50 | #obj_offre.poste = offre_dict('poste') |
| 51 | obj_offre.date_limite = offre_dict('date_limite') |
| 52 | obj_offre.region = offre_dict('region') |
| 53 | obj_offre.bureau = offre_dict('bureau') |
| 54 | obj_offre.duree_affectation = offre_dict('duree_affectation') |
| 55 | obj_offre.renumeration = offre_dict('renumeration') |
| 56 | obj_offre.debut_affectation = offre_dict('debut_affectation') |
| 57 | obj_offre.lieu_affectation = offre_dict('lieu_affectation') |
| 58 | return obj_offre |
| 59 | |