-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
422fcc6
commit e02f5d0
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
# coding: utf-8 | ||
|
||
""" | ||
Import objectives and rates from CSV format | ||
@author: Sébastien Renard ([email protected]) | ||
@license: AGPL v3 or newer (http://www.gnu.org/licenses/agpl-3.0.html) | ||
""" | ||
|
||
import csv | ||
from datetime import datetime | ||
import sys | ||
import os | ||
from os.path import abspath, join, pardir, dirname | ||
|
||
|
||
# # Setup django envt & django imports | ||
PYDICI_DIR = abspath(join(dirname(__file__), pardir)) | ||
os.environ['DJANGO_SETTINGS_MODULE'] = "pydici.settings" | ||
|
||
sys.path.append(PYDICI_DIR) # Add project path to python path | ||
|
||
# Ensure we are in the good current working directory (pydici home) | ||
os.chdir(PYDICI_DIR) | ||
|
||
# Init and model loading | ||
from django.core.wsgi import get_wsgi_application | ||
application = get_wsgi_application() | ||
|
||
# Pydici imports | ||
from people.models import Consultant, RateObjective | ||
|
||
objectives = csv.reader(open(sys.argv[1], "r")) | ||
|
||
for line in objectives: | ||
if not line[0] or line[0]=="Consultant": | ||
continue | ||
try: | ||
c = Consultant.objects.get(trigramme=line[0]) | ||
except: | ||
print(f"Warning, no consultant for {line[0]}") | ||
continue | ||
start = datetime.strptime(line[21], "%Y-%m-%d") | ||
prod_rate = float(line[10].strip("%")) | ||
daily_rate = int(line[7]) | ||
RateObjective.objects.get_or_create(consultant=c, start_date=start, rate=daily_rate, rate_type="DAILY_RATE") | ||
RateObjective.objects.get_or_create(consultant=c, start_date=start, rate=prod_rate, rate_type="PROD_RATE") | ||
|