Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
D
django-representatives-votes
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Ce projet est archivé. Le dépôt et les autres ressources du projet sont en lecture seule.
Afficher davantage de fils d'Ariane
La Quadrature du Net
Political Memory
django-representatives-votes
Validations
c5fe59b2
Valider
c5fe59b2
rédigé
9 years ago
par
Arnaud Fabre
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
adds command to import 1 proposal
parent
e787f2dd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
representatives_votes/management/commands/import_proposal_from_toutatis.py
+45
-0
45 ajouts, 0 suppression
...otes/management/commands/import_proposal_from_toutatis.py
representatives_votes/utils.py
+1
-0
1 ajout, 0 suppression
representatives_votes/utils.py
avec
46 ajouts
et
0 suppression
representatives_votes/management/commands/import_proposal_from_toutatis.py
0 → 100644
+
45
−
0
Voir le fichier @
c5fe59b2
# coding: utf-8
# This file is part of toutatis.
#
# toutatis is free software: you can redistribute it and/or modify
# 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 any later version.
#
# toutatis is distributed in the hope that it will
# be useful, 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 General Affero Public
# License along with Foobar.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2013 Laurent Peuch <cortex@worlddomination.be>
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
import
json
from
urllib2
import
urlopen
from
django.core.management.base
import
BaseCommand
from
django.conf
import
settings
from
representatives_votes.utils
import
import_a_dossier
class
Command
(
BaseCommand
):
def
handle
(
self
,
*
args
,
**
options
):
proposal_id
=
args
[
0
]
toutatis_server
=
getattr
(
settings
,
'
TOUTATIS_SERVER
'
,
'
http://toutatis.mm.staz.be
'
)
proposal_url
=
'
{}/api/proposals/{}
'
.
format
(
toutatis_server
,
proposal_id
)
print
(
'
Import proposal from {}
'
.
format
(
proposal_url
))
proposal_data
=
json
.
load
(
urlopen
(
proposal_url
))
dossier_url
=
proposal_data
[
'
dossier
'
]
dossier_data
=
json
.
load
(
urlopen
(
dossier_url
))
# Replace dossier proposals by the one proposal we want
dossier_data
[
'
proposals
'
]
=
[
proposal_data
]
import_a_dossier
(
dossier_data
)
Ce diff est replié.
Cliquez pour l'agrandir.
representatives_votes/utils.py
+
1
−
0
Voir le fichier @
c5fe59b2
...
...
@@ -23,6 +23,7 @@ from representatives_votes.serializers import DossierDetailSerializer
# Import a dossier
def
import_a_dossier
(
data
):
serializer
=
DossierDetailSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter