Skip to content

Commit f3d543f

Browse files
Alvaro PerezAlvaro Perez
authored andcommitted
Merge branch 'Sprint2' of https://github.com/data-me/api2 into Sprint2
2 parents 8248142 + 41653a5 commit f3d543f

File tree

11 files changed

+102
-13
lines changed

11 files changed

+102
-13
lines changed

Aptfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
libssl-dev
2+
libffi-dev

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
release: sh -c 'cd mysite && python manage.py migrate'
1+
release: sh -c 'cd mysite && python manage.py makemigrations pagos && python manage.py migrate'
22
web: sh -c 'cd mysite && gunicorn mysite.wsgi --log-file -'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.7 on 2019-04-11 23:30
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('datame', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='userplan',
15+
name='isPayed',
16+
field=models.BooleanField(default=False),
17+
),
18+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 2.1.7 on 2019-04-12 03:23
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('datame', '0002_userplan_ispayed'),
10+
('datame', '0002_auto_20190411_2237'),
11+
]
12+
13+
operations = [
14+
]

mysite/datame/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class UserPlan(models.Model):
5151
type = models.CharField('Type', max_length = 4, choices = TYPE_CHOICES)
5252
startDate = models.DateTimeField(null = True)
5353
expirationDate = models.DateTimeField(null = True)
54+
isPayed = models.BooleanField(default= False)
5455

5556
def __str__(self):
5657
res = 'User Plan from ' + self.dataScientist.name

mysite/datame/populate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def populate(request):
3434
photo='https://media.istockphoto.com/photos/portrait-of-a-german-businessman-with-beard-picture-id480286744',
3535
address='C/Cristo del Amor Number 21',phone='955766587')
3636

37-
userPlan1 = UserPlan.objects.create(type='PRO',dataScientist=dataScientist1,startDate=datetime.datetime(2019,1,1,0,0,0,0,pytz.UTC),expirationDate=datetime.datetime(2020,1,1,0,0,0,0,pytz.UTC))
37+
userPlan1 = UserPlan.objects.create(type='PRO',dataScientist=dataScientist1,startDate=datetime.datetime(2019,1,1,0,0,0,0,pytz.UTC),expirationDate=datetime.datetime(2020,1,1,0,0,0,0,pytz.UTC),isPayed=True)
3838

3939
company01 = Company.objects.create(user = company1, name = 'Endesa', description = 'Endesa, fundada como «Empresa Nacional de Electricidad Sociedad Anónima» y cuyo nombre legal es Endesa, S.A., es una empresa española que opera en los sectores eléctrico y gasístico.',nif = '44060644A', logo = 'https://graffica.info/wp-content/uploads/2016/01/Captura-de-pantalla-2016-01-28-a-las-19.00.55.png')
4040
company02 = Company.objects.create(user = company2, name = 'Everis', description = 'Somos everis an NTT DATA Company, nos dedicamos a la consultoría y outsourcing abarcando todos los sectores del ámbito económico, llegando a facturar en el último ejercicio fiscal cerca de 1.173 millones de euros.',nif = '45070745B', logo = 'https://worldfootballsummit.com/wp-content/uploads/2018/08/logo-vector-everis.jpg')

mysite/datame/userplan.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def get(self, request, format=None):
2626
# List userplan as administrator
2727
assert logged_user.is_staff
2828
dataScientist = DataScientist.objects.all().get(pk=request.GET.get('dataScientistId'))
29-
userPlanHistory = list(UserPlan.objects.filter(dataScientist=dataScientist).values())
29+
userPlanHistory = list(UserPlan.objects.filter(dataScientist=dataScientist)
30+
.filter(isPayed=True).values())
3031
response.update({
3132
'userId': str(logged_user.id),
3233
'dataScientistId': str(dataScientist.id),
@@ -55,7 +56,8 @@ def get(self, request, format=None):
5556
except:
5657
return JsonResponse({"message": "Sorry, there was a problem retrieving the Data Scientist"})
5758
try:
58-
userPlanHistory = UserPlan.objects.filter(dataScientist=dataScientist).order_by('-expirationDate')
59+
userPlanHistory = UserPlan.objects.filter(dataScientist=dataScientist)\
60+
.filter(isPayed=True).order_by('-expirationDate')
5961
response['dataScientistId'] = dataScientist.id
6062
currentUserPlan = None
6163
if 0 < userPlanHistory.count():
@@ -83,7 +85,7 @@ def post(self, request, format=None):
8385
dataScientist = DataScientist.objects.all().get(user=logged_user)
8486
except:
8587
return JsonResponse({"message": "Only data scientists can update their user plan."})
86-
userPlanHistory = UserPlan.objects.filter(dataScientist=dataScientist).order_by('-expirationDate')
88+
userPlanHistory = UserPlan.objects.filter(dataScientist=dataScientist).filter(isPayed=True).order_by('-expirationDate')
8789
currentUserPlan = None
8890
if 0 < userPlanHistory.count():
8991
currentUserPlan = userPlanHistory.first()

mysite/mysite/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
'django.middleware.common.CommonMiddleware',
7777
)
7878

79-
BASEURL = 'http://localhost:8000'
79+
BASEURL = 'https://front2-datame.herokuapp.com'
8080

8181
ROOT_URLCONF = 'mysite.urls'
8282

@@ -179,7 +179,7 @@
179179
PAYPAL_CLIENT_ID = "AQnKuEyaCgxZsEBPC-aq3glrpVK1dcTUUbvjkmnguZOM1WLQnsEU-y7i2oh3VkM_Xm4AfbJQx8AKdiYF"
180180
PAYPAL_CLIENT_SECRET = "EEkGJcVWziLr8FnQFC-BCYX0bcSz_xyh3POT7iR1K9e7fxFLVhI9EJSnOl5Jn3d_UhqydqGEYTfzCozc"
181181

182-
SITE_URL ='http://localhost:8080/'
182+
SITE_URL ='https://front2-datame.herokuapp.com/'
183183

184184
import django_heroku
185185
django_heroku.settings(locals())
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 2.1.7 on 2019-04-11 16:16
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('pagos', '0002_auto_20190411_0800'),
10+
('pagos', '0002_userplanpaypalbill'),
11+
]
12+
13+
operations = [
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 2.1.7 on 2019-04-12 03:23
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('pagos', '0003_merge_20190411_1816'),
10+
('pagos', '0004_merge_20190411_2213'),
11+
]
12+
13+
operations = [
14+
]

0 commit comments

Comments
 (0)