From a732dadcb0cf7bd73d2bcb4294ecc7d14fcd808d Mon Sep 17 00:00:00 2001 From: Apostolof Date: Thu, 10 Jan 2019 00:59:07 +0200 Subject: [PATCH] Add API support for restaurant addition and filtering --- .../__pycache__/__init__.cpython-35.pyc | Bin 131 -> 0 bytes .../__pycache__/settings.cpython-35.pyc | Bin 2544 -> 0 bytes .../__pycache__/urls.cpython-35.pyc | Bin 1097 -> 0 bytes .../__pycache__/wsgi.cpython-35.pyc | Bin 560 -> 0 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 139 -> 0 bytes .../hyrieus/__pycache__/admin.cpython-35.pyc | Bin 964 -> 0 bytes .../hyrieus/__pycache__/models.cpython-35.pyc | Bin 9703 -> 0 bytes .../__pycache__/serializers.cpython-35.pyc | Bin 6647 -> 0 bytes .../hyrieus/__pycache__/urls.cpython-35.pyc | Bin 1517 -> 0 bytes .../hyrieus/__pycache__/views.cpython-35.pyc | Bin 5831 -> 0 bytes .../hyrieus/flavoursAPI/hyrieus/admin.py | 7 +- .../hyrieus/migrations/0001_initial.py | 116 ++++--- .../__pycache__/0001_initial.cpython-35.pyc | Bin 6262 -> 0 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 150 -> 0 bytes .../hyrieus/flavoursAPI/hyrieus/models.py | 66 ++-- .../flavoursAPI/hyrieus/serializers.py | 48 ++- .../hyrieus/flavoursAPI/hyrieus/urls.py | 30 +- .../hyrieus/flavoursAPI/hyrieus/views.py | 294 +++++++++++++++--- .../hyrieus/flavoursAPI/settings.py | 34 +- 19 files changed, 425 insertions(+), 170 deletions(-) delete mode 100644 UI/Database API/hyrieus/flavoursAPI/__pycache__/__init__.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/__pycache__/settings.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/__pycache__/urls.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/__pycache__/wsgi.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/__init__.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/admin.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/models.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/serializers.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/urls.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/views.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/0001_initial.cpython-35.pyc delete mode 100644 UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/__init__.cpython-35.pyc diff --git a/UI/Database API/hyrieus/flavoursAPI/__pycache__/__init__.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/__pycache__/__init__.cpython-35.pyc deleted file mode 100644 index 697db6dbbc48507023cfde992f655a484418d473..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131 zcmWgR<>gu%q#wfo1dl-k3@`#24nSPY0whux7=kq!{Z=v*frJsnF9ZFI{M=Oiw4B7U z{L-T0lqCI(%A(BF(qg!fV}PfAe0*kJW=VX!UP0w84x8Nkl+v73JCI4mK+FIDOp+dX diff --git a/UI/Database API/hyrieus/flavoursAPI/__pycache__/settings.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/__pycache__/settings.cpython-35.pyc deleted file mode 100644 index a0e230daaca7b7085f17322114919dfea50c3f15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2544 zcmb7GZByGu5MIAv8wW_5kc1{_qqcd21lb0X&`u|fVk_W@u|1XujixgiS$DPtdU13o z2>RMz(vSTE{W1F5PyGx1)Rk<5Ycf-6ne%FI_u1$6cJH{gxLEw-x6&`mivWMZ)Cb?; zHU2R*1wa5a98*BjV5dM!0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UI/Database API/hyrieus/flavoursAPI/__pycache__/urls.cpython-35.pyc deleted file mode 100644 index d7b6b068bb2ded98e9a4b6bf2eeda2a4915cbf92..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1097 zcma)5U2oGc6un8)uWW^hhlxkOb&*P}@mK+3nwXe`5aQz{LUd{EwyEMcvYo;Dx}U(W z;4kHsC;kFYT)QcYkdT%rj(v4~?m5TT$D>gge5apH2jC~Po-WQ`;-|MbFn|O{510?R z2f~NM2hXlMkas`?kOaGR0C^Wg50c()-G#glVgShi#1N7pcsu~s1Mb5ngv|lm`oIUk z`oM?425{@y$O;P_0vp1IC`^qHu*}nISt)(??vi|Z|Aw5)VwtTfm6}WzVfb;)$yKHD zGBt*)LSKEFQgMUcj8RBH`{qGR}>B0R~p-Z!yQLa z_zN2!BCqbIOk@R40_!;b2bvp$8g%5>9b{4W8-Q)krP6KpOIl`h`?%G%@%lz(ywVQ- zZ8WO;vl%wmY?eG|^q>t!Wpjn?4)sAxq{6#-7qM=s03*rK-NvPZRrb=Vp3M$)W_TS~ zkLrU~-~0eIvPpLMJ)yQy=$<8;(}v{V5Z*V}*l~GN51t9hs+_-gh&DG64{4GN0>>Y<^XPe)BHxgtG4j?Rm!3;rIW;$UVsL?mFJzV#rpxY|BP_boTjl*uTt1=hxSRVSkie zT%O&0Iln*Lnn3C?1Z_*->$cr2BO6)PGUwZajhQs39@16mhLKp?MZ3_Avu#2|g@v4( z(7xDG{RK@z57+STn4DKAp7hkMm@XTQbN`&8PgpmT*2{M9-Dbq^_o#qhL5IC$2kaI5 E57^DBo&W#< diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/__init__.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/__init__.cpython-35.pyc deleted file mode 100644 index bd62fef0bc5d8b0c8ef786ce6751ad3a7a7c68cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139 zcmWgR<>fjbq#wfo1dl-k3@`#24nSPY0whux7=kq!{Z=v*frJsnFAM#Q{M=Oiw4B7U z{L-T0lqCI(%A(BF(qg!fV}K`IEIvLnFS8^*Uaz3?7Kcr4eoARhsvXG0VjyM!0DrF` A+W-In diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/admin.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/admin.cpython-35.pyc deleted file mode 100644 index fbab449127267fe63b1527a9eec2d3e54e5feda2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 964 zcmaKqL5|Zf6o&t_Nt>oknzX~f0oZgiU9m$5q|u1kpsI+C#U>@Db&2E3PC>Kg3Uh&3 zasdwGEvvZ#EBrcAr&x$M`I7Iw*nZOUd736a@8%zOUEmi^u8#YD?H+R*0F}D~)PM}Y z0t8hDRTp&!vJ2LQ48cOk2rPo^f%PE!V139KEQTC_4ImS+1ab&AgdBm5AXBguG6TyX z$6#Z~94v<{zzWC-*aUJ4HbuY#Y|pTL0^Y@UxBsJuo=2YdJnwrRdp__y@qFm{$n(_m z%=5A5x#xxF6VImyuR^?^MfcRMSzx2GlA^hHeZs7;;icfMeM($twGk`Pn(Jn*c_nz$ z+UQb?=8K&iUT@3ORCuLSWeeipiR5H{vfx?@V}xpKvgD>M_qufJhD%j*TM*sklb^y5 zhHE<}Ua7iP-^@dS6!=$x86}ow%gsZj>Cq46O^^Dx`McRU%c^bJtkuOQ)wEiyG@W1D zld9si(V-I^5qg9^Atnq631LVW5mG`%7!z_rL6{Jxgfj;l8qsnaYrYny<@yKoGs+Qu zznE{7tpQDzl+_CjbFNg_ceb-y)@4q@?h7=ga3~| D6qVmP diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/models.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/models.cpython-35.pyc deleted file mode 100644 index 81a13c67dc086d28a94206d3cc06d80b57a9dfa8..0000000000000000000000000000000000000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em+-+6MAYyDB zd&SsP5T6NFN!erS@n2X$?PA6Pp;cRK)v*2LOFYEg#t?Ki2Ms}eDjK@ zlvEKu3UQJ2999qJ$f^%OSU%TFRneU?K+enexZr+9icP%c2h5e|fZ-3PPoTBb<#PO&9kn~Mp$9GQ8aScDj6Thczs|p>cg~RpBR3ji+!X*E9 z$g4+)pu*f(;K{erZ#g;enu%pX+%+`ZQT0#3?gmziVaG*3pzaQOr$*hM@$jpl?mC{A zv@cFCB$W&qZ1Ts{;^NaLwcepyrjL3T(igbK0f}Vef%Gp(rl+u?uvHxcd=zmOWf}RX zrtw_kHEJss!>>jZdFfAqm|15vM77i=lT$ z8COCXljChI!dtvph`MDBb#XGUuy++J$Jo=p&;tUuA)6Y3|HQ+i2wWN)9FOBYsv2-H zhQE5n diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/serializers.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/serializers.cpython-35.pyc deleted file mode 100644 index 68eabdba79905ec7533a44d97decffaf6cc6cb1f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6647 zcmcJT-BQ~|7=}Op8~_jNXz?dz4$~QNMQ)whTs5Bp1-4-PikSzel_4-CZaabC3SoeLg=!^bdJ{l6=3% zm;EqKB=|2zCXp2*Ek-dBCy^jCPF8}n1X)Sal4PYwOOcf(ElpO2v0ltxB<{B1s}ee{wTY zWW?yV8olEu&(l+pCXrD>#v?4SkR>srgc*-eXCX%-uY|luSY)9ntph zSXRQaM`*IJLSj`3s~(}n!WxNnC9Hdd4HlXtT1sengfpN1d3Hw+-3rn!UG%wBN^2R&kR1J!9b1ksizbMenRPun#U@NJI3D%Yl>H zm%YoE&Yb%9tm~DMPx^h~RFIAfIZyrEu_3LVZTI?@PVU682i+^#W#8mU-!z;GQm*Xz zQ1VA^q*F%vq;H!2*YtZ-|X>aw>dEg z!-+?i7H6h>7gtQ<^e&EZ#bfNWlXOaG(diK7m>s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MWDrSXW>i4 z#Z35`TZ9YGUw|9!Gs(Cmpv7?K;7i2)l+`EPB3yX>0^DfNNX8umS`2p{zC_&5Sp6Hf z2p69Iaf{fAlR?XXih(Y`mk9bftGnDHP&x84j z>@S&p7@RTo75Ea_zhw1CZV@{?{j-nta?C%;CPsi4Ltce15gB{N3vLlIJpCh&_K^R0 ze;x&0j2P*0GVxce9&?L`;pv}vx<~x~EXreGjB#IsFEP@OSUuwwal^wIevXrA%)&6w zH$L~;zWc#o(tH-q^kK}ZfeQqFxx=q?-to&GezC({o1Bd9+T>=a_cG)ypTI9hP*CK< z>_PLS-8tVq!iDicwvP4ZAKT&_&~Aj}?n zN;ZP95LG5dqK+IrOrN;HOF)8_xW0H(=#FKBg{y~i$S3k}nEV$Wk;NmjctjYE9-Vrq zkJA{b71+9?qZ*C#y*Gzg!<+ApKE11U_}Y4SwE?BqVK~Bk)30A}Demw98yBuZDD+th z2}GE6mGYDyj_Qcq-P)>u{dl{+zw`I+cMc9~wt9-wpTRtb!7d&TgMIG#L5Bq&X(Cy} zR>>+@(NguWR_#LVo&$|0_pc?hYQNZsz z{9pNteu@pH-b_Y8|L`Q92eCTrTmFLDV-ps2l_}le)N>RzPvf4t9>Wt>fIR2sXW4KC zX%FSKZ@2a^tT<IA+5Pgqtwd+NuEYvNa)`bnkX%yMDu^0+eG=@x^! z&eBzjt_To0RfN&WpiZ&M=;~~sf+M|k={-QNs(PWquRbhBGt}4BbhotBRhzDXrtx*1 zuInUNr*c2FfON7X}%=Lf)*9 zjVk1L3i*>lI-;=EE9{*Ln-I@*HdrauBR1jahhf{ez`Hc{7`mRZcoJ7VqA>rU`_kbd XCY6u!x?)wV^O5t>Df`d$x-;Qt^ diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/admin.py b/UI/Database API/hyrieus/flavoursAPI/hyrieus/admin.py index 340d896..33da03e 100644 --- a/UI/Database API/hyrieus/flavoursAPI/hyrieus/admin.py +++ b/UI/Database API/hyrieus/flavoursAPI/hyrieus/admin.py @@ -1,5 +1,10 @@ from django.contrib import admin -from .models import Diet, DietProhibitsIngredient, Drink, DrinkHasIngredient, Food, FoodHasIngredient, Ingredient, Permission, Restaurant, Role, RoleHasPermission, User, UserFollowsDiet, UserProhibitsIngredient, UserRatesDrink, UserRatesFood, UserRatesRestaurant +from .models import (Diet, + DietProhibitsIngredient, Drink, DrinkHasIngredient, Food, FoodHasIngredient, + Ingredient, Permission, Restaurant, Role, RoleHasPermission, User, + UserFollowsDiet, UserProhibitsIngredient, UserRatesDrink, UserRatesFood, + UserRatesRestaurant, +) admin.site.register(Diet) admin.site.register(DietProhibitsIngredient) diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/0001_initial.py b/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/0001_initial.py index a80d929..086df8e 100644 --- a/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/0001_initial.py +++ b/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/0001_initial.py @@ -1,7 +1,11 @@ -# Generated by Django 2.1.4 on 2019-01-04 16:17 +# Generated by Django 2.1.4 on 2019-01-09 11:35 +from django.conf import settings +import django.contrib.auth.models +import django.contrib.auth.validators from django.db import migrations, models import django.db.models.deletion +import django.utils.timezone class Migration(migrations.Migration): @@ -9,20 +13,46 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('auth', '0009_alter_user_last_name_max_length'), ] operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('user_age', models.DateField(null=True)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ], + options={ + 'managed': True, + 'db_table': 'user', + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), migrations.CreateModel( name='Diet', fields=[ - ('diet_id', models.IntegerField(primary_key=True, serialize=False)), + ('diet_id', models.AutoField(primary_key=True, serialize=False)), ('diet_name', models.CharField(max_length=500)), ('diet_description', models.CharField(blank=True, max_length=700, null=True)), ('diet_is_approved', models.BooleanField(default=False)), ], options={ - 'db_table': 'diet', 'managed': True, + 'db_table': 'diet', }, ), migrations.CreateModel( @@ -32,21 +62,21 @@ class Migration(migrations.Migration): ('diet', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Diet')), ], options={ - 'db_table': 'diet_prohibits_ingredient', 'managed': True, + 'db_table': 'diet_prohibits_ingredient', }, ), migrations.CreateModel( name='Drink', fields=[ - ('drink_id', models.IntegerField(primary_key=True, serialize=False)), + ('drink_id', models.AutoField(primary_key=True, serialize=False)), ('drink_name', models.CharField(max_length=500)), ('drink_description', models.CharField(blank=True, max_length=700, null=True)), ('drink_is_approved', models.BooleanField(default=False)), ], options={ - 'db_table': 'drink', 'managed': True, + 'db_table': 'drink', }, ), migrations.CreateModel( @@ -56,22 +86,22 @@ class Migration(migrations.Migration): ('drink', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Drink')), ], options={ - 'db_table': 'drink_has_ingredient', 'managed': True, + 'db_table': 'drink_has_ingredient', }, ), migrations.CreateModel( name='Food', fields=[ - ('food_id', models.IntegerField(primary_key=True, serialize=False)), + ('food_id', models.AutoField(primary_key=True, serialize=False)), ('food_name', models.CharField(max_length=500)), ('food_description', models.CharField(blank=True, max_length=700, null=True)), ('food_calories', models.IntegerField(blank=True, null=True)), ('food_is_approved', models.BooleanField(default=False)), ], options={ - 'db_table': 'food', 'managed': True, + 'db_table': 'food', }, ), migrations.CreateModel( @@ -81,8 +111,8 @@ class Migration(migrations.Migration): ('food', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Food')), ], options={ - 'db_table': 'food_has_ingredient', 'managed': True, + 'db_table': 'food_has_ingredient', }, ), migrations.CreateModel( @@ -92,25 +122,25 @@ class Migration(migrations.Migration): ('ingredient_has_alcohol', models.BooleanField(blank=True, default=False, null=True)), ], options={ - 'db_table': 'ingredient', 'managed': True, + 'db_table': 'ingredient', }, ), migrations.CreateModel( name='Permission', fields=[ - ('permission_id', models.IntegerField(primary_key=True, serialize=False)), + ('permission_id', models.AutoField(primary_key=True, serialize=False)), ('permission_description', models.CharField(max_length=700)), ], options={ - 'db_table': 'permission', 'managed': True, + 'db_table': 'permission', }, ), migrations.CreateModel( name='Restaurant', fields=[ - ('restaurant_id', models.IntegerField(primary_key=True, serialize=False)), + ('restaurant_id', models.AutoField(primary_key=True, serialize=False)), ('restaurant_name', models.CharField(max_length=500)), ('restaurant_category', models.CharField(max_length=10)), ('restaurant_longitude', models.FloatField()), @@ -118,10 +148,11 @@ class Migration(migrations.Migration): ('restaurant_opening', models.TimeField(blank=True, null=True)), ('restaurant_closing', models.TimeField(blank=True, null=True)), ('restaurant_is_approved', models.BooleanField(default=False)), + ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), ], options={ - 'db_table': 'restaurant', 'managed': True, + 'db_table': 'restaurant', }, ), migrations.CreateModel( @@ -132,8 +163,8 @@ class Migration(migrations.Migration): ('role_description', models.CharField(max_length=700)), ], options={ - 'db_table': 'role', 'managed': True, + 'db_table': 'role', }, ), migrations.CreateModel( @@ -144,24 +175,8 @@ class Migration(migrations.Migration): ('role', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Role')), ], options={ - 'db_table': 'role_has_permission', - 'managed': True, - }, - ), - migrations.CreateModel( - name='User', - fields=[ - ('user_id', models.IntegerField(primary_key=True, serialize=False)), - ('user_email', models.CharField(max_length=500)), - ('user_username', models.CharField(max_length=500)), - ('user_hashed_password', models.CharField(max_length=64)), - ('user_salt', models.CharField(max_length=32)), - ('user_age', models.DateField()), - ('role', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Role')), - ], - options={ - 'db_table': 'user', 'managed': True, + 'db_table': 'role_has_permission', }, ), migrations.CreateModel( @@ -169,11 +184,11 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('diet', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Diet')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.User')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), ], options={ - 'db_table': 'user_follows_diet', 'managed': True, + 'db_table': 'user_follows_diet', }, ), migrations.CreateModel( @@ -181,11 +196,11 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('ingredient_name', models.ForeignKey(db_column='ingredient_name', on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Ingredient')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.User')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), ], options={ - 'db_table': 'user_prohibits_ingredient', 'managed': True, + 'db_table': 'user_prohibits_ingredient', }, ), migrations.CreateModel( @@ -197,11 +212,11 @@ class Migration(migrations.Migration): ('rating_text', models.CharField(blank=True, max_length=700, null=True)), ('rating_pοrtion_size', models.CharField(blank=True, max_length=6, null=True)), ('drink', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Drink')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.User')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), ], options={ - 'db_table': 'user_rates_drink', 'managed': True, + 'db_table': 'user_rates_drink', }, ), migrations.CreateModel( @@ -213,11 +228,11 @@ class Migration(migrations.Migration): ('rating_text', models.CharField(blank=True, max_length=700, null=True)), ('rating_pοrtion_size', models.CharField(blank=True, max_length=6, null=True)), ('food', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Food')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.User')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), ], options={ - 'db_table': 'user_rates_food', 'managed': True, + 'db_table': 'user_rates_food', }, ), migrations.CreateModel( @@ -230,18 +245,13 @@ class Migration(migrations.Migration): ('rating_accessibility', models.CharField(blank=True, max_length=8, null=True)), ('diet', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Diet')), ('restaurant', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Restaurant')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.User')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), ], options={ - 'db_table': 'user_rates_restaurant', 'managed': True, + 'db_table': 'user_rates_restaurant', }, ), - migrations.AddField( - model_name='restaurant', - name='user', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.User'), - ), migrations.AddField( model_name='foodhasingredient', name='ingredient_name', @@ -267,6 +277,16 @@ class Migration(migrations.Migration): name='ingredient_name', field=models.ForeignKey(db_column='ingredient_name', on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Ingredient'), ), + migrations.AddField( + model_name='user', + name='role', + field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Role'), + ), + migrations.AddField( + model_name='user', + name='user_permissions', + field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'), + ), migrations.AlterUniqueTogether( name='userratesrestaurant', unique_together={('user', 'restaurant')}, diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/0001_initial.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/0001_initial.cpython-35.pyc deleted file mode 100644 index 103da2a91098cec29d16c9c899ff20d8fe6414a0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6262 zcmd5=S$EsU6&^q!DMF<7rLMbJty5K5BqdIlv}t0+tZX&4>?(4TFbe{5MkFW@paIaf z)HQa`>2K+O$T|53{Q>jZC%yN{Prdg71coA!Q0X~66-DsQH+SxSX8^2LtLFOOw?FQ^ z&e*@0@@D{j6TacwaN+Q;F_*Ef#_AgD>a4Ca4N;xBQ><>V+kA>~gZ&L4g9(jw3hWt7 z6p-V+&B8edVVk-%yG|>xBggkbS?u~;xZyz)=LUZ-0C5w(;U`tb1Ve402DE|x`V?yc z4e|@DQ$)$JQeI%9#5&WA0|@*j#;4gcrXK@CnWoB&n~cu@s3BMxfK}p$saeM7kbcId zkYSz}0AGkj;i{Iw_#)#=j4w03g3OMN{FyPU=sRDdwKI%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vLs;Gx-0In3_}CBlIliHh zWts|YH#)zD<7pa0XG#MpIrjjrd%o-Xk3;OLtjBOdE)e^1Ja1vc$u*o9*U)9y0-C9PhQJ{w@{GenPkL)Ass~GNz`8kkCMsWKferc z`?5mV^3IFs>O3igc@bK1GgnhR)Gl)h19pyFO6L#LI)%!Mjj@|e0Zq_wTqim`p9T$? zn+p4iB2+0Plis7nO;@0uyS{)rA!*=gvM1IT$P;TVfabI%Wi)AHVhGq}h*w%78d&KqzP;W36=s9C#b9o##*vwv_~ zntQHqM~RRlrz;Y&21Of_)4QC<)Y7gSiQoaH_bAD(G+~3o`h-`t|6sxA7!15TzrEe| zyJGv;wIBKYAmokhWDiQA-TV6~mc8%Y-r3oC6^=2A(N^y?FhE)fzTs22Td3$oy=auR zqJC9d(bl!AQ$?*Zh2stFm6V=fE@$PswxLMLq@%_`I0>UjNE*nPw-yQa(0|a7#y}wZ$7$x^cB$ nNx`l7t^L-Z=z_;s8JNqgMq=tIU~>A+xLe-Bq7RX674rHY%|p%L diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/__init__.cpython-35.pyc b/UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/__init__.cpython-35.pyc deleted file mode 100644 index 9e2137af63bdbca873f6a5dcfb0edfd6cf0d3ca8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmWgR<>gXr*NLF~AcpmYbPglvt9PpI59OAD@|*SrQ+wS5SG2!zMRBr8Fni L4rF*S5HkP(^c5x9 diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/models.py b/UI/Database API/hyrieus/flavoursAPI/hyrieus/models.py index dc2d91e..93a5df6 100644 --- a/UI/Database API/hyrieus/flavoursAPI/hyrieus/models.py +++ b/UI/Database API/hyrieus/flavoursAPI/hyrieus/models.py @@ -1,7 +1,26 @@ from django.db import models +from django.contrib.auth.models import AbstractUser +from django.conf import settings + +class Role(models.Model): + role_id = models.IntegerField(primary_key=True) + role_name = models.CharField(max_length=500) + role_description = models.CharField(max_length=700) + + class Meta: + managed = True + db_table = 'role' + +class User(AbstractUser): + role = models.ForeignKey(Role, models.DO_NOTHING, default=0) + user_age = models.DateField(null=True) + + class Meta: + managed = True + db_table = 'user' class Diet(models.Model): - diet_id = models.IntegerField(primary_key=True) + diet_id = models.AutoField(primary_key=True) diet_name = models.CharField(max_length=500) diet_description = models.CharField(max_length=700, blank=True, null=True) diet_is_approved = models.BooleanField(default=False) @@ -21,7 +40,7 @@ class DietProhibitsIngredient(models.Model): unique_together = (('diet', 'ingredient_name'),) class Drink(models.Model): - drink_id = models.IntegerField(primary_key=True) + drink_id = models.AutoField(primary_key=True) drink_name = models.CharField(max_length=500) drink_description = models.CharField(max_length=700, blank=True, null=True) drink_is_approved = models.BooleanField(default=False) @@ -43,7 +62,7 @@ class DrinkHasIngredient(models.Model): class Food(models.Model): - food_id = models.IntegerField(primary_key=True) + food_id = models.AutoField(primary_key=True) food_name = models.CharField(max_length=500) food_description = models.CharField(max_length=700, blank=True, null=True) food_calories = models.IntegerField(blank=True, null=True) @@ -74,7 +93,7 @@ class Ingredient(models.Model): class Permission(models.Model): - permission_id = models.IntegerField(primary_key=True) + permission_id = models.AutoField(primary_key=True) permission_description = models.CharField(max_length=700) class Meta: @@ -83,7 +102,7 @@ class Permission(models.Model): class Restaurant(models.Model): - restaurant_id = models.IntegerField(primary_key=True) + restaurant_id = models.AutoField(primary_key=True) restaurant_name = models.CharField(max_length=500) restaurant_category = models.CharField(max_length=10) restaurant_longitude = models.FloatField() @@ -91,23 +110,12 @@ class Restaurant(models.Model): restaurant_opening = models.TimeField(blank=True, null=True) restaurant_closing = models.TimeField(blank=True, null=True) restaurant_is_approved = models.BooleanField(default=False) - user = models.ForeignKey('User', models.DO_NOTHING, blank=True, null=True) + user = models.ForeignKey(settings.AUTH_USER_MODEL, models.DO_NOTHING, blank=True, null=True) class Meta: managed = True db_table = 'restaurant' - -class Role(models.Model): - role_id = models.IntegerField(primary_key=True) - role_name = models.CharField(max_length=500) - role_description = models.CharField(max_length=700) - - class Meta: - managed = True - db_table = 'role' - - class RoleHasPermission(models.Model): role = models.ForeignKey(Role, models.DO_NOTHING) permission = models.ForeignKey(Permission, models.DO_NOTHING) @@ -118,22 +126,8 @@ class RoleHasPermission(models.Model): unique_together = (('role', 'permission'),) -class User(models.Model): - user_id = models.IntegerField(primary_key=True) - user_email = models.CharField(max_length=500) - user_username = models.CharField(max_length=500) - user_hashed_password = models.CharField(max_length=64) - user_salt = models.CharField(max_length=32) - role = models.ForeignKey(Role, models.DO_NOTHING) - user_age = models.DateField() - - class Meta: - managed = True - db_table = 'user' - - class UserFollowsDiet(models.Model): - user = models.ForeignKey(User, models.DO_NOTHING) + user = models.ForeignKey(settings.AUTH_USER_MODEL, models.DO_NOTHING) diet = models.ForeignKey(Diet, models.DO_NOTHING) class Meta: @@ -143,7 +137,7 @@ class UserFollowsDiet(models.Model): class UserProhibitsIngredient(models.Model): - user = models.ForeignKey(User, models.DO_NOTHING) + user = models.ForeignKey(settings.AUTH_USER_MODEL, models.DO_NOTHING) ingredient_name = models.ForeignKey(Ingredient, models.DO_NOTHING, db_column='ingredient_name') class Meta: @@ -153,7 +147,7 @@ class UserProhibitsIngredient(models.Model): class UserRatesDrink(models.Model): - user = models.ForeignKey(User, models.DO_NOTHING) + user = models.ForeignKey(settings.AUTH_USER_MODEL, models.DO_NOTHING) drink = models.ForeignKey(Drink, models.DO_NOTHING) rating_grade = models.IntegerField() rating_date = models.DateField() @@ -167,7 +161,7 @@ class UserRatesDrink(models.Model): class UserRatesFood(models.Model): - user = models.ForeignKey(User, models.DO_NOTHING) + user = models.ForeignKey(settings.AUTH_USER_MODEL, models.DO_NOTHING) food = models.ForeignKey(Food, models.DO_NOTHING) rating_grade = models.IntegerField() rating_date = models.DateField() @@ -181,7 +175,7 @@ class UserRatesFood(models.Model): class UserRatesRestaurant(models.Model): - user = models.ForeignKey(User, models.DO_NOTHING) + user = models.ForeignKey(settings.AUTH_USER_MODEL, models.DO_NOTHING) restaurant = models.ForeignKey(Restaurant, models.DO_NOTHING) diet = models.ForeignKey(Diet, models.DO_NOTHING, blank=True, null=True) rating_grade = models.IntegerField() diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/serializers.py b/UI/Database API/hyrieus/flavoursAPI/hyrieus/serializers.py index 97a3e51..a81661b 100644 --- a/UI/Database API/hyrieus/flavoursAPI/hyrieus/serializers.py +++ b/UI/Database API/hyrieus/flavoursAPI/hyrieus/serializers.py @@ -1,22 +1,10 @@ from rest_framework import serializers +from rest_framework.authtoken.models import Token from .models import ( - Diet, - DietProhibitsIngredient, - Drink, - DrinkHasIngredient, - Food, - FoodHasIngredient, - Ingredient, - Permission, - Restaurant, - Role, - RoleHasPermission, - User, - UserFollowsDiet, - UserProhibitsIngredient, - UserRatesDrink, - UserRatesFood, - UserRatesRestaurant, + Diet, DietProhibitsIngredient, Drink, DrinkHasIngredient, Food, + FoodHasIngredient, Ingredient, Permission, Restaurant, Role, + RoleHasPermission, User, UserFollowsDiet, UserProhibitsIngredient, + UserRatesDrink, UserRatesFood, UserRatesRestaurant, ) class DietSerializer(serializers.ModelSerializer): @@ -64,6 +52,16 @@ class RestaurantSerializer(serializers.ModelSerializer): model = Restaurant fields = '__all__' + def create(self, validated_data): + user = None + request = self.context.get("request") + if request and hasattr(request, "user"): + user = request.user + user = User.objects.get(username=user) + validated_data['restaurant_is_approved'] = True if (user.role.role_id == 1) else False + restaurant = Restaurant.objects.create(**validated_data) + return restaurant + class RoleSerializer(serializers.ModelSerializer): class Meta: model = Role @@ -79,6 +77,16 @@ class UserSerializer(serializers.ModelSerializer): model = User fields = '__all__' +class UserPublicInfoSerializer(UserSerializer): + class Meta: + model = User + fields = ( + 'id', + 'role', + 'username' + ) + + class UserFollowsDietSerializer(serializers.ModelSerializer): class Meta: model = UserFollowsDiet @@ -103,3 +111,9 @@ class UserRatesRestaurantSerializer(serializers.ModelSerializer): class Meta: model = UserRatesRestaurant fields = '__all__' + +class FlavoursTokenSerializer(serializers.ModelSerializer): + user = UserPublicInfoSerializer(many=False, read_only=True) + class Meta: + model = Token + fields = ('key', 'user') \ No newline at end of file diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/urls.py b/UI/Database API/hyrieus/flavoursAPI/hyrieus/urls.py index 4b87c81..79c8bef 100644 --- a/UI/Database API/hyrieus/flavoursAPI/hyrieus/urls.py +++ b/UI/Database API/hyrieus/flavoursAPI/hyrieus/urls.py @@ -1,23 +1,12 @@ from django.conf.urls import url +from django.urls import include, path from rest_framework import routers -from flavoursAPI.hyrieus.views import (DietViewSet, - DietProhibitsIngredientViewSet, - DrinkViewSet, - DrinkHasIngredientViewSet, - FoodViewSet, - FoodHasIngredientViewSet, - IngredientViewSet, - PermissionViewSet, - RestaurantViewSet, - RoleViewSet, - RoleHasPermissionViewSet, - UserViewSet, - UserFollowsDietViewSet, - UserProhibitsIngredientViewSet, - UserRatesDrinkViewSet, - UserRatesFoodViewSet, - UserRatesRestaurantViewSet, - Signup, +from flavoursAPI.hyrieus.views import (DietViewSet, DietProhibitsIngredientViewSet, + DrinkViewSet, DrinkHasIngredientViewSet, FoodViewSet, FoodHasIngredientViewSet, + IngredientViewSet, PermissionViewSet, RestaurantViewSet, RoleViewSet, + RoleHasPermissionViewSet, UserViewSet, UserFollowsDietViewSet, + UserProhibitsIngredientViewSet, UserRatesDrinkViewSet, UserRatesFoodViewSet, + UserRatesRestaurantViewSet, UserSetBirthDay, ) router = routers.DefaultRouter() @@ -40,7 +29,10 @@ router.register(r'userratesfood', UserRatesFoodViewSet) router.register(r'userratesrestaurant', UserRatesRestaurantViewSet) urlpatterns = [ - url(r'signup', Signup.as_view()), + # url(r'signup', Signup.as_view()), + path('setUserBirthday//', UserSetBirthDay.as_view(), name='setUserBirthday'), + path('rest-auth/', include('rest_auth.urls')), + url(r'^rest-auth/registration/', include('rest_auth.registration.urls')) ] urlpatterns += router.urls \ No newline at end of file diff --git a/UI/Database API/hyrieus/flavoursAPI/hyrieus/views.py b/UI/Database API/hyrieus/flavoursAPI/hyrieus/views.py index ecfcf54..463fe19 100644 --- a/UI/Database API/hyrieus/flavoursAPI/hyrieus/views.py +++ b/UI/Database API/hyrieus/flavoursAPI/hyrieus/views.py @@ -1,127 +1,327 @@ from django.shortcuts import render +from decimal import Decimal +from django.db.models import F, ExpressionWrapper, FloatField +from rest_framework.views import APIView from rest_framework import viewsets -from .models import ( - Diet, - DietProhibitsIngredient, - Drink, - DrinkHasIngredient, - Food, - FoodHasIngredient, - Ingredient, - Permission, - Restaurant, - Role, - RoleHasPermission, - User, - UserFollowsDiet, - UserProhibitsIngredient, - UserRatesDrink, - UserRatesFood, - UserRatesRestaurant, +from rest_framework.authentication import SessionAuthentication, BasicAuthentication +from rest_framework.permissions import IsAuthenticated +from rest_framework.response import Response +from rest_framework.exceptions import PermissionDenied + +from .models import (Diet, DietProhibitsIngredient, Drink, DrinkHasIngredient, + Food, FoodHasIngredient, Ingredient, Permission, Restaurant, Role, + RoleHasPermission, User, UserFollowsDiet, UserProhibitsIngredient, + UserRatesDrink, UserRatesFood, UserRatesRestaurant, ) from .serializers import ( - DietSerializer, - DietProhibitsIngredientSerializer, - DrinkSerializer, - DrinkHasIngredientSerializer, - FoodSerializer, - FoodHasIngredientSerializer, - IngredientSerializer, - PermissionSerializer, - RestaurantSerializer, - RoleSerializer, - RoleHasPermissionSerializer, - UserSerializer, - UserFollowsDietSerializer, - UserProhibitsIngredientSerializer, - UserRatesDrinkSerializer, - UserRatesFoodSerializer, + DietSerializer, DietProhibitsIngredientSerializer, DrinkSerializer, + DrinkHasIngredientSerializer, FoodSerializer, FoodHasIngredientSerializer, + IngredientSerializer, PermissionSerializer, RestaurantSerializer, + RoleSerializer, RoleHasPermissionSerializer, UserSerializer, + UserFollowsDietSerializer, UserProhibitsIngredientSerializer, + UserRatesDrinkSerializer, UserRatesFoodSerializer, UserRatesRestaurantSerializer, ) class DietViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Diet.objects.all() serializer_class = DietSerializer class DietProhibitsIngredientViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = DietProhibitsIngredient.objects.all() serializer_class = DietProhibitsIngredientSerializer class DrinkViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Drink.objects.all() serializer_class = DrinkSerializer class DrinkHasIngredientViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = DrinkHasIngredient.objects.all() serializer_class = DrinkHasIngredientSerializer class FoodViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Food.objects.all() serializer_class = FoodSerializer class FoodHasIngredientViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = FoodHasIngredient.objects.all() serializer_class = FoodHasIngredientSerializer class IngredientViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Ingredient.objects.all() serializer_class = IngredientSerializer class PermissionViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Permission.objects.all() serializer_class = PermissionSerializer class RestaurantViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get_queryset(self): + user = self.request.user + filterType = self.request.query_params.get('filter_restaurant_type', None) + filterDistanceRadius = self.request.query_params.get('filter_restaurant_radius', None) + filterDistanceLongitude = self.request.query_params.get('filter_restaurant_longitude', None) + filterDistanceLatitude = self.request.query_params.get('filter_restaurant_latitude', None) + filterCalories = self.request.query_params.get('filter_restaurant_calories', None) + + restaurants = Restaurant.objects.all() + if filterDistanceRadius is not None: + filterDistanceRadius = float(filterDistanceRadius) + filterDistanceLongitude = float(filterDistanceLongitude) + filterDistanceLatitude = float(filterDistanceLatitude) + + import math + restaurants = restaurants.filter( + restaurant_latitude__range=(filterDistanceLatitude-(filterDistanceRadius/111.045), + filterDistanceLatitude+(filterDistanceRadius/111.045))) + restaurants = restaurants.filter( + restaurant_longitude__range=(filterDistanceLongitude-(filterDistanceRadius/(111.045*math.cos(math.radians(filterDistanceLatitude)))), + filterDistanceLongitude+(filterDistanceRadius/(111.045*math.cos(math.radians(filterDistanceLatitude)))))) + + # ====================================================================================== + # WHY THE FUCK DOES BELOW CODE FAIL? :-( + # ====================================================================================== + + # restaurants = restaurants.annotate(distance = + # 111.045 * math.degrees(math.acos( + # math.cos(math.radians(filterDistanceLatitude)) + # * math.cos(math.radians(F('restaurant_latitude'))) + # * math.cos(math.radians(filterDistanceLongitude - float(F('restaurant_longitude')))) + # + math.sin(math.radians(filterDistanceLatitude)) + # * math.sin(math.radians(F('restaurant_latitude'))) + # ))) + # restaurants = restaurants.filter(distance__lt=filterDistanceRadius) + # restaurants = restaurants.order_by('distance') + restaurants = restaurants.distinct(); + + if filterType is not None: + restaurants = restaurants.filter(restaurant_category=filterType) + + if not user.role.role_id == 1: + restaurants = restaurants.filter(restaurant_is_approved=True) + + return restaurants + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Restaurant.objects.all() serializer_class = RestaurantSerializer class RoleViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = Role.objects.all() serializer_class = RoleSerializer class RoleHasPermissionViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = RoleHasPermission.objects.all() serializer_class = RoleHasPermissionSerializer class UserViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = User.objects.all() serializer_class = UserSerializer class UserFollowsDietViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = UserFollowsDiet.objects.all() serializer_class = UserFollowsDietSerializer class UserProhibitsIngredientViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = UserProhibitsIngredient.objects.all() serializer_class = UserProhibitsIngredientSerializer class UserRatesDrinkViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = UserRatesDrink.objects.all() serializer_class = UserRatesDrinkSerializer class UserRatesFoodViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = UserRatesFood.objects.all() serializer_class = UserRatesFoodSerializer class UserRatesRestaurantViewSet(viewsets.ModelViewSet): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) + + def get(self, request, format=None): + content = { + 'user': unicode(request.user), + 'auth': unicode(request.auth), + } + return Response(content) + queryset = UserRatesRestaurant.objects.all() serializer_class = UserRatesRestaurantSerializer -from rest_framework.views import APIView, Response +class UserSetBirthDay(APIView): + authentication_classes = (SessionAuthentication, BasicAuthentication) + permission_classes = (IsAuthenticated,) -class Signup(APIView): - def get(self, request, format=None): - serializer = User.objects.all() - return Response(serializer.data, status=status.HTTP_201_CREATED) + def put(self, request, pk, format=None): + try: + user = User.objects.get(pk=pk) + except Snippet.DoesNotExist: + raise Http404 - def post(self, request, format=None): - serializer = UserSerializer(data=request.data) + if not request.user == user: + raise PermissionDenied({"message":"You don't have permission to access"}) + + serializer = UserSerializer(user, data=request.data, partial=True) if serializer.is_valid(): serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - + return Response(serializer.data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - @classmethod - def get_extra_actions(cls): - return [] diff --git a/UI/Database API/hyrieus/flavoursAPI/settings.py b/UI/Database API/hyrieus/flavoursAPI/settings.py index 2971066..2e08c31 100644 --- a/UI/Database API/hyrieus/flavoursAPI/settings.py +++ b/UI/Database API/hyrieus/flavoursAPI/settings.py @@ -38,9 +38,17 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'flavoursAPI.hyrieus', + 'rest_auth', 'rest_framework', + 'rest_framework.authtoken', + 'rest_auth.registration', + 'allauth.account', + 'allauth', + 'django.contrib.sites', ] +SITE_ID = 1 + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -82,7 +90,6 @@ DATABASES = { 'USER': 'flavoursUser', 'PASSWORD': 'flavours13', 'HOST': '83.212.109.171', - # 'HOST': '127.0.0.1', 'PORT': '', }, } @@ -126,4 +133,27 @@ USE_TZ = True STATIC_URL = '/static/' -SILENCED_SYSTEM_CHECKS = ['mysql.E001'] \ No newline at end of file +SILENCED_SYSTEM_CHECKS = ['mysql.E001'] + +AUTH_USER_MODEL = 'hyrieus.User' + +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.BasicAuthentication', + 'rest_framework.authentication.SessionAuthentication', + 'rest_framework.authentication.TokenAuthentication', + ) +} + +REST_AUTH_SERIALIZERS = { + 'TOKEN_SERIALIZER': 'flavoursAPI.hyrieus.serializers.FlavoursTokenSerializer', +} + +AUTHENTICATION_BACKENDS = ( + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +) + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +ACCOUNT_EMAIL_VERIFICATION = 'none' +ACCOUNT_AUTHENTICATION_METHOD = 'username_email'