Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions etc/cyclos/init_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,6 @@ def create_user(group, name, login, password=None, custom_values=None):
login=login,
)

porteurs = {
'P001': 'Porteur 1',
'P002': 'Porteur 2',
'P003': 'Porteur 3',
'P004': 'Porteur 4',
}
for login, name in porteurs.items():
create_user(
group='Porteurs',
name=name,
login=login,
)

# Récupération des constantes

logger.info('Récupération des constantes depuis le YAML...')
Expand Down
10 changes: 1 addition & 9 deletions etc/cyclos/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def add_custom_field_to_transfer_type(transfer_type_id, custom_field_id):
ID_CHAMP_PERSO_PAIEMENT_BDC = create_transaction_custom_field_linked_user(
name='BDC',
)
ID_CHAMP_PERSO_PAIEMENT_PORTEUR = create_transaction_custom_field_linked_user(
ID_CHAMP_PERSO_PAIEMENT_PORTEUR = create_transaction_custom_field_text(
name='Porteur',
)
ID_CHAMP_PERSO_PAIEMENT_ADHERENT = create_transaction_custom_field_linked_user(
Expand Down Expand Up @@ -2181,13 +2181,6 @@ def change_group_configuration(group_id, configuration_id):
'login',
],
)
# Porteurs.
ID_GROUPE_PORTEURS = create_member_group(
name='Porteurs',
products=[
ID_PRODUIT_UTILISATEURS_BASIQUES_SANS_COMPTE,
]
)
# Adhérents sans compte.
ID_GROUPE_ADHERENTS_SANS_COMPTE = create_member_group(
name='Adhérents sans compte',
Expand All @@ -2203,7 +2196,6 @@ def change_group_configuration(group_id, configuration_id):
ID_GROUPE_COMPTES_DEDIES,
ID_GROUPE_ADHERENTS_PRESTATAIRES,
ID_GROUPE_ADHERENTS_UTILISATEURS,
ID_GROUPE_PORTEURS,
ID_GROUPE_ADHERENTS_SANS_COMPTE,
]

Expand Down
10 changes: 5 additions & 5 deletions src/api/bdc_cyclos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def entree_stock(request):
for payment in request.data['selected_payments']:
try:
porteur = [
value['linkedEntityValue']['id']
value['stringValue']
for value in payment['customValues']
if value['field']['id'] == str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']) and
value['field']['internalName'] == 'porteur'
Expand Down Expand Up @@ -215,7 +215,7 @@ def entree_stock(request):
'customValues': [
{
'field': str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']),
'linkedEntityValue': porteur # ID du porteur
'stringValue': porteur # ID du porteur
},
],
'description': description,
Expand Down Expand Up @@ -262,7 +262,7 @@ def sortie_stock(request):
'customValues': [
{
'field': str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']),
'linkedEntityValue': request.data['porteur'] # ID du porteur
'stringValue': request.data['porteur'] # ID du porteur
},
],
'description': request.data['description'],
Expand Down Expand Up @@ -708,7 +708,7 @@ def cash_deposit(request):
cash_deposit_data.update({'customValues': [
{
'field': str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']),
'linkedEntityValue': porteur # ID du porteur
'stringValue': porteur # ID du porteur
},
]})

Expand Down Expand Up @@ -780,7 +780,7 @@ def sortie_retour_eusko(request):
},
{
'field': str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']),
'linkedEntityValue': request.data['porteur'] # ID du porteur
'stringValue': request.data['porteur'] # ID du porteur
},
],
# "Sortie retour d'eusko - Bxxx - Nom du BDC
Expand Down
20 changes: 13 additions & 7 deletions src/api/euskalmoneta_data/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rest_framework.response import Response

from cyclos_api import CyclosAPI, CyclosAPIException
from dolibarr_api import DolibarrAPI, DolibarrAPIException


@api_view(['GET'])
Expand All @@ -26,15 +27,20 @@ def porteurs_eusko(request):
List porteurs d'euskos.
"""
try:
cyclos = CyclosAPI(token=request.user.profile.cyclos_token)
except CyclosAPIException:
return Response({'error': 'Unable to connect to Cyclos!'}, status=status.HTTP_400_BAD_REQUEST)
dolibarr = DolibarrAPI(api_key=request.user.profile.dolibarr_token)
except DolibarrAPIException:
return Response({'error': 'Unable to connect to Dolibarr!'}, status=status.HTTP_400_BAD_REQUEST)

categories = dolibarr.get(model='categories')
porteur_category_id = -1
for c in categories:
if c['label'] == 'porteur':
porteur_category_id = c['id']

# user/search for group = 'Porteurs'
porteurs_data = cyclos.post(method='user/search',
data={'groups': [settings.CYCLOS_CONSTANTS['groups']['porteurs']]})
res = [{'label': item['display'], 'value': item['id']}
for item in porteurs_data['result']['pageItems']]
porteurs_data = dolibarr.get(model='categories/' + porteur_category_id + '/objects', type='member')
res = [{'label': item['firstname'] + ' ' + item['lastname'], 'value': item['firstname'] + ' ' + item['lastname']}
for item in porteurs_data]

return Response(res)

Expand Down
6 changes: 3 additions & 3 deletions src/api/gestioninterne/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def sortie_coffre(request):
},
{
'field': str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']),
'linkedEntityValue': request.data['porteur'] # porteur sélectionné par l'utilisateur
'stringValue': request.data['porteur'] # porteur sélectionné par l'utilisateur
},
],
'description': request.data['description'], # description saisie par l'utilisateur
Expand Down Expand Up @@ -107,7 +107,7 @@ def entree_coffre(request):

try:
porteur_id = [
value['linkedEntityValue']['id']
value['stringValue']
for value in payment['customValues']
if value['field']['id'] == str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']) and
value['field']['internalName'] == 'porteur'
Expand Down Expand Up @@ -136,7 +136,7 @@ def entree_coffre(request):
},
{
'field': str(settings.CYCLOS_CONSTANTS['transaction_custom_fields']['porteur']),
'linkedEntityValue': porteur_id # porteur de l'opération d'origine
'stringValue': porteur_id # porteur de l'opération d'origine
},
]

Expand Down