-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-elimina-tutor-en-campo-socio.py
executable file
·52 lines (34 loc) · 1.27 KB
/
3-elimina-tutor-en-campo-socio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import configparser
import os
import requests
import common
config = configparser.ConfigParser()
config.read(os.path.expanduser("~/.avast.ini"))
socios = common.readjson("socios")
token = common.gettoken(
user=config["auth"]["RWusername"], password=config["auth"]["RWpassword"]
)
headers = {"Authorization": f"Bearer {token}"}
print("Procesando socios")
count = 0
idsociotoclean = []
for socio in socios:
if isinstance(socio["campsDinamics"], dict):
if common.socioid in socio["campsDinamics"]:
mysocio = socio["campsDinamics"][common.socioid]
for field in [common.tutor1, common.tutor2]:
if field in socio["campsDinamics"]:
if mysocio == socio["campsDinamics"][field]:
idsociotoclean.append(socio["idColegiat"])
for idcolegiat in sorted(set(idsociotoclean)):
count = count + 1
print(
"%s https://asociacionavast.playoffinformatica.com/FormAssociat.php?idColegiat=%s"
% (f"{count:04}", idcolegiat)
)
comurl = f"{common.apiurl}/colegiats/{idcolegiat}/campsdinamics"
data = {f"{common.socioid}": ""}
files = []
response = requests.request("PUT", comurl, headers=headers, data=data, files=files)
print(response)