Browse Source

Init API

master
Apostolos Fanakis 6 years ago
parent
commit
c910307a3f
  1. 1
      UI/Database API/hyrieus/.gitignore
  2. 0
      UI/Database API/hyrieus/flavoursAPI/__init__.py
  3. BIN
      UI/Database API/hyrieus/flavoursAPI/__pycache__/__init__.cpython-35.pyc
  4. BIN
      UI/Database API/hyrieus/flavoursAPI/__pycache__/settings.cpython-35.pyc
  5. BIN
      UI/Database API/hyrieus/flavoursAPI/__pycache__/urls.cpython-35.pyc
  6. BIN
      UI/Database API/hyrieus/flavoursAPI/__pycache__/wsgi.cpython-35.pyc
  7. 0
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__init__.py
  8. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/__init__.cpython-35.pyc
  9. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/admin.cpython-35.pyc
  10. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/models.cpython-35.pyc
  11. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/serializers.cpython-35.pyc
  12. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/urls.cpython-35.pyc
  13. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/views.cpython-35.pyc
  14. 20
      UI/Database API/hyrieus/flavoursAPI/hyrieus/admin.py
  15. 5
      UI/Database API/hyrieus/flavoursAPI/hyrieus/apps.py
  16. 306
      UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/0001_initial.py
  17. 0
      UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__init__.py
  18. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/0001_initial.cpython-35.pyc
  19. BIN
      UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/__init__.cpython-35.pyc
  20. 195
      UI/Database API/hyrieus/flavoursAPI/hyrieus/models.py
  21. 105
      UI/Database API/hyrieus/flavoursAPI/hyrieus/serializers.py
  22. 3
      UI/Database API/hyrieus/flavoursAPI/hyrieus/tests.py
  23. 46
      UI/Database API/hyrieus/flavoursAPI/hyrieus/urls.py
  24. 127
      UI/Database API/hyrieus/flavoursAPI/hyrieus/views.py
  25. 129
      UI/Database API/hyrieus/flavoursAPI/settings.py
  26. 24
      UI/Database API/hyrieus/flavoursAPI/urls.py
  27. 16
      UI/Database API/hyrieus/flavoursAPI/wsgi.py
  28. 15
      UI/Database API/hyrieus/manage.py

1
UI/Database API/hyrieus/.gitignore

@ -0,0 +1 @@
/env/

0
UI/Database API/hyrieus/flavoursAPI/__init__.py

BIN
UI/Database API/hyrieus/flavoursAPI/__pycache__/__init__.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/__pycache__/settings.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/__pycache__/urls.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/__pycache__/wsgi.cpython-35.pyc

Binary file not shown.

0
UI/Database API/hyrieus/flavoursAPI/hyrieus/__init__.py

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/__init__.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/admin.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/models.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/serializers.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/urls.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/__pycache__/views.cpython-35.pyc

Binary file not shown.

20
UI/Database API/hyrieus/flavoursAPI/hyrieus/admin.py

@ -0,0 +1,20 @@
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
admin.site.register(Diet)
admin.site.register(DietProhibitsIngredient)
admin.site.register(Drink)
admin.site.register(DrinkHasIngredient)
admin.site.register(Food)
admin.site.register(FoodHasIngredient)
admin.site.register(Ingredient)
admin.site.register(Permission)
admin.site.register(Restaurant)
admin.site.register(Role)
admin.site.register(RoleHasPermission)
admin.site.register(User)
admin.site.register(UserFollowsDiet)
admin.site.register(UserProhibitsIngredient)
admin.site.register(UserRatesDrink)
admin.site.register(UserRatesFood)
admin.site.register(UserRatesRestaurant)

5
UI/Database API/hyrieus/flavoursAPI/hyrieus/apps.py

@ -0,0 +1,5 @@
from django.apps import AppConfig
class HyrieusConfig(AppConfig):
name = 'hyrieus'

306
UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/0001_initial.py

@ -0,0 +1,306 @@
# Generated by Django 2.1.4 on 2019-01-04 16:17
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Diet',
fields=[
('diet_id', models.IntegerField(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,
},
),
migrations.CreateModel(
name='DietProhibitsIngredient',
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')),
],
options={
'db_table': 'diet_prohibits_ingredient',
'managed': True,
},
),
migrations.CreateModel(
name='Drink',
fields=[
('drink_id', models.IntegerField(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,
},
),
migrations.CreateModel(
name='DrinkHasIngredient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('drink', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Drink')),
],
options={
'db_table': 'drink_has_ingredient',
'managed': True,
},
),
migrations.CreateModel(
name='Food',
fields=[
('food_id', models.IntegerField(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,
},
),
migrations.CreateModel(
name='FoodHasIngredient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('food', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Food')),
],
options={
'db_table': 'food_has_ingredient',
'managed': True,
},
),
migrations.CreateModel(
name='Ingredient',
fields=[
('ingredient_name', models.CharField(max_length=500, primary_key=True, serialize=False)),
('ingredient_has_alcohol', models.BooleanField(blank=True, default=False, null=True)),
],
options={
'db_table': 'ingredient',
'managed': True,
},
),
migrations.CreateModel(
name='Permission',
fields=[
('permission_id', models.IntegerField(primary_key=True, serialize=False)),
('permission_description', models.CharField(max_length=700)),
],
options={
'db_table': 'permission',
'managed': True,
},
),
migrations.CreateModel(
name='Restaurant',
fields=[
('restaurant_id', models.IntegerField(primary_key=True, serialize=False)),
('restaurant_name', models.CharField(max_length=500)),
('restaurant_category', models.CharField(max_length=10)),
('restaurant_longitude', models.FloatField()),
('restaurant_latitude', models.FloatField()),
('restaurant_opening', models.TimeField(blank=True, null=True)),
('restaurant_closing', models.TimeField(blank=True, null=True)),
('restaurant_is_approved', models.BooleanField(default=False)),
],
options={
'db_table': 'restaurant',
'managed': True,
},
),
migrations.CreateModel(
name='Role',
fields=[
('role_id', models.IntegerField(primary_key=True, serialize=False)),
('role_name', models.CharField(max_length=500)),
('role_description', models.CharField(max_length=700)),
],
options={
'db_table': 'role',
'managed': True,
},
),
migrations.CreateModel(
name='RoleHasPermission',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('permission', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Permission')),
('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,
},
),
migrations.CreateModel(
name='UserFollowsDiet',
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')),
],
options={
'db_table': 'user_follows_diet',
'managed': True,
},
),
migrations.CreateModel(
name='UserProhibitsIngredient',
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')),
],
options={
'db_table': 'user_prohibits_ingredient',
'managed': True,
},
),
migrations.CreateModel(
name='UserRatesDrink',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rating_grade', models.IntegerField()),
('rating_date', models.DateField()),
('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')),
],
options={
'db_table': 'user_rates_drink',
'managed': True,
},
),
migrations.CreateModel(
name='UserRatesFood',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rating_grade', models.IntegerField()),
('rating_date', models.DateField()),
('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')),
],
options={
'db_table': 'user_rates_food',
'managed': True,
},
),
migrations.CreateModel(
name='UserRatesRestaurant',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rating_grade', models.IntegerField()),
('rating_date', models.DateField()),
('rating_text', models.CharField(blank=True, max_length=700, null=True)),
('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')),
],
options={
'db_table': 'user_rates_restaurant',
'managed': True,
},
),
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',
field=models.ForeignKey(db_column='ingredient_name', on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Ingredient'),
),
migrations.AddField(
model_name='food',
name='restaurant',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Restaurant'),
),
migrations.AddField(
model_name='drinkhasingredient',
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='drink',
name='restaurant',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Restaurant'),
),
migrations.AddField(
model_name='dietprohibitsingredient',
name='ingredient_name',
field=models.ForeignKey(db_column='ingredient_name', on_delete=django.db.models.deletion.DO_NOTHING, to='hyrieus.Ingredient'),
),
migrations.AlterUniqueTogether(
name='userratesrestaurant',
unique_together={('user', 'restaurant')},
),
migrations.AlterUniqueTogether(
name='userratesfood',
unique_together={('user', 'food')},
),
migrations.AlterUniqueTogether(
name='userratesdrink',
unique_together={('user', 'drink')},
),
migrations.AlterUniqueTogether(
name='userprohibitsingredient',
unique_together={('user', 'ingredient_name')},
),
migrations.AlterUniqueTogether(
name='userfollowsdiet',
unique_together={('user', 'diet')},
),
migrations.AlterUniqueTogether(
name='rolehaspermission',
unique_together={('role', 'permission')},
),
migrations.AlterUniqueTogether(
name='foodhasingredient',
unique_together={('food', 'ingredient_name')},
),
migrations.AlterUniqueTogether(
name='drinkhasingredient',
unique_together={('drink', 'ingredient_name')},
),
migrations.AlterUniqueTogether(
name='dietprohibitsingredient',
unique_together={('diet', 'ingredient_name')},
),
]

0
UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__init__.py

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/0001_initial.cpython-35.pyc

Binary file not shown.

BIN
UI/Database API/hyrieus/flavoursAPI/hyrieus/migrations/__pycache__/__init__.cpython-35.pyc

Binary file not shown.

195
UI/Database API/hyrieus/flavoursAPI/hyrieus/models.py

@ -0,0 +1,195 @@
from django.db import models
class Diet(models.Model):
diet_id = models.IntegerField(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)
class Meta:
managed = True
db_table = 'diet'
class DietProhibitsIngredient(models.Model):
diet = models.ForeignKey(Diet, models.DO_NOTHING)
ingredient_name = models.ForeignKey('Ingredient', models.DO_NOTHING, db_column='ingredient_name')
class Meta:
managed = True
db_table = 'diet_prohibits_ingredient'
unique_together = (('diet', 'ingredient_name'),)
class Drink(models.Model):
drink_id = models.IntegerField(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)
restaurant = models.ForeignKey('Restaurant', models.DO_NOTHING)
class Meta:
managed = True
db_table = 'drink'
class DrinkHasIngredient(models.Model):
drink = models.ForeignKey(Drink, models.DO_NOTHING)
ingredient_name = models.ForeignKey('Ingredient', models.DO_NOTHING, db_column='ingredient_name')
class Meta:
managed = True
db_table = 'drink_has_ingredient'
unique_together = (('drink', 'ingredient_name'),)
class Food(models.Model):
food_id = models.IntegerField(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)
food_is_approved = models.BooleanField(default=False)
restaurant = models.ForeignKey('Restaurant', models.DO_NOTHING)
class Meta:
managed = True
db_table = 'food'
class FoodHasIngredient(models.Model):
food = models.ForeignKey(Food, models.DO_NOTHING)
ingredient_name = models.ForeignKey('Ingredient', models.DO_NOTHING, db_column='ingredient_name')
class Meta:
managed = True
db_table = 'food_has_ingredient'
unique_together = (('food', 'ingredient_name'),)
class Ingredient(models.Model):
ingredient_name = models.CharField(primary_key=True, max_length=500)
ingredient_has_alcohol = models.BooleanField(default=False, blank=True, null=True)
class Meta:
managed = True
db_table = 'ingredient'
class Permission(models.Model):
permission_id = models.IntegerField(primary_key=True)
permission_description = models.CharField(max_length=700)
class Meta:
managed = True
db_table = 'permission'
class Restaurant(models.Model):
restaurant_id = models.IntegerField(primary_key=True)
restaurant_name = models.CharField(max_length=500)
restaurant_category = models.CharField(max_length=10)
restaurant_longitude = models.FloatField()
restaurant_latitude = models.FloatField()
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)
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)
class Meta:
managed = True
db_table = 'role_has_permission'
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)
diet = models.ForeignKey(Diet, models.DO_NOTHING)
class Meta:
managed = True
db_table = 'user_follows_diet'
unique_together = (('user', 'diet'),)
class UserProhibitsIngredient(models.Model):
user = models.ForeignKey(User, models.DO_NOTHING)
ingredient_name = models.ForeignKey(Ingredient, models.DO_NOTHING, db_column='ingredient_name')
class Meta:
managed = True
db_table = 'user_prohibits_ingredient'
unique_together = (('user', 'ingredient_name'),)
class UserRatesDrink(models.Model):
user = models.ForeignKey(User, models.DO_NOTHING)
drink = models.ForeignKey(Drink, models.DO_NOTHING)
rating_grade = models.IntegerField()
rating_date = models.DateField()
rating_text = models.CharField(max_length=700, blank=True, null=True)
rating_pοrtion_size = models.CharField(max_length=6, blank=True, null=True)
class Meta:
managed = True
db_table = 'user_rates_drink'
unique_together = (('user', 'drink'),)
class UserRatesFood(models.Model):
user = models.ForeignKey(User, models.DO_NOTHING)
food = models.ForeignKey(Food, models.DO_NOTHING)
rating_grade = models.IntegerField()
rating_date = models.DateField()
rating_text = models.CharField(max_length=700, blank=True, null=True)
rating_pοrtion_size = models.CharField(max_length=6, blank=True, null=True)
class Meta:
managed = True
db_table = 'user_rates_food'
unique_together = (('user', 'food'),)
class UserRatesRestaurant(models.Model):
user = models.ForeignKey(User, 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()
rating_date = models.DateField()
rating_text = models.CharField(max_length=700, blank=True, null=True)
rating_accessibility = models.CharField(max_length=8, blank=True, null=True)
class Meta:
managed = True
db_table = 'user_rates_restaurant'
unique_together = (('user', 'restaurant'),)

105
UI/Database API/hyrieus/flavoursAPI/hyrieus/serializers.py

@ -0,0 +1,105 @@
from rest_framework import serializers
from .models import (
Diet,
DietProhibitsIngredient,
Drink,
DrinkHasIngredient,
Food,
FoodHasIngredient,
Ingredient,
Permission,
Restaurant,
Role,
RoleHasPermission,
User,
UserFollowsDiet,
UserProhibitsIngredient,
UserRatesDrink,
UserRatesFood,
UserRatesRestaurant,
)
class DietSerializer(serializers.ModelSerializer):
class Meta:
model = Diet
fields = '__all__'
class DietProhibitsIngredientSerializer(serializers.ModelSerializer):
class Meta:
model = DietProhibitsIngredient
fields = '__all__'
class DrinkSerializer(serializers.ModelSerializer):
class Meta:
model = Drink
fields = '__all__'
class DrinkHasIngredientSerializer(serializers.ModelSerializer):
class Meta:
model = DrinkHasIngredient
fields = '__all__'
class FoodSerializer(serializers.ModelSerializer):
class Meta:
model = Food
fields = '__all__'
class FoodHasIngredientSerializer(serializers.ModelSerializer):
class Meta:
model = FoodHasIngredient
fields = '__all__'
class IngredientSerializer(serializers.ModelSerializer):
class Meta:
model = Ingredient
fields = '__all__'
class PermissionSerializer(serializers.ModelSerializer):
class Meta:
model = Permission
fields = '__all__'
class RestaurantSerializer(serializers.ModelSerializer):
class Meta:
model = Restaurant
fields = '__all__'
class RoleSerializer(serializers.ModelSerializer):
class Meta:
model = Role
fields = '__all__'
class RoleHasPermissionSerializer(serializers.ModelSerializer):
class Meta:
model = RoleHasPermission
fields = '__all__'
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = '__all__'
class UserFollowsDietSerializer(serializers.ModelSerializer):
class Meta:
model = UserFollowsDiet
fields = '__all__'
class UserProhibitsIngredientSerializer(serializers.ModelSerializer):
class Meta:
model = UserProhibitsIngredient
fields = '__all__'
class UserRatesDrinkSerializer(serializers.ModelSerializer):
class Meta:
model = UserRatesDrink
fields = '__all__'
class UserRatesFoodSerializer(serializers.ModelSerializer):
class Meta:
model = UserRatesFood
fields = '__all__'
class UserRatesRestaurantSerializer(serializers.ModelSerializer):
class Meta:
model = UserRatesRestaurant
fields = '__all__'

3
UI/Database API/hyrieus/flavoursAPI/hyrieus/tests.py

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

46
UI/Database API/hyrieus/flavoursAPI/hyrieus/urls.py

@ -0,0 +1,46 @@
from django.conf.urls import url
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,
)
router = routers.DefaultRouter()
router.register(r'diet', DietViewSet)
router.register(r'dietprohibitsingredient', DietProhibitsIngredientViewSet)
router.register(r'drink', DrinkViewSet)
router.register(r'drinkhasingredient', DrinkHasIngredientViewSet)
router.register(r'food', FoodViewSet)
router.register(r'foodhasingredient', FoodHasIngredientViewSet)
router.register(r'ingredient', IngredientViewSet)
router.register(r'permission', PermissionViewSet)
router.register(r'restaurant', RestaurantViewSet)
router.register(r'role', RoleViewSet)
router.register(r'rolehaspermission', RoleHasPermissionViewSet)
router.register(r'user', UserViewSet)
router.register(r'userfollowsdiet', UserFollowsDietViewSet)
router.register(r'userprohibitsingredient', UserProhibitsIngredientViewSet)
router.register(r'userratesdrink', UserRatesDrinkViewSet)
router.register(r'userratesfood', UserRatesFoodViewSet)
router.register(r'userratesrestaurant', UserRatesRestaurantViewSet)
urlpatterns = [
url(r'signup', Signup.as_view()),
]
urlpatterns += router.urls

127
UI/Database API/hyrieus/flavoursAPI/hyrieus/views.py

@ -0,0 +1,127 @@
from django.shortcuts import render
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 .serializers import (
DietSerializer,
DietProhibitsIngredientSerializer,
DrinkSerializer,
DrinkHasIngredientSerializer,
FoodSerializer,
FoodHasIngredientSerializer,
IngredientSerializer,
PermissionSerializer,
RestaurantSerializer,
RoleSerializer,
RoleHasPermissionSerializer,
UserSerializer,
UserFollowsDietSerializer,
UserProhibitsIngredientSerializer,
UserRatesDrinkSerializer,
UserRatesFoodSerializer,
UserRatesRestaurantSerializer,
)
class DietViewSet(viewsets.ModelViewSet):
queryset = Diet.objects.all()
serializer_class = DietSerializer
class DietProhibitsIngredientViewSet(viewsets.ModelViewSet):
queryset = DietProhibitsIngredient.objects.all()
serializer_class = DietProhibitsIngredientSerializer
class DrinkViewSet(viewsets.ModelViewSet):
queryset = Drink.objects.all()
serializer_class = DrinkSerializer
class DrinkHasIngredientViewSet(viewsets.ModelViewSet):
queryset = DrinkHasIngredient.objects.all()
serializer_class = DrinkHasIngredientSerializer
class FoodViewSet(viewsets.ModelViewSet):
queryset = Food.objects.all()
serializer_class = FoodSerializer
class FoodHasIngredientViewSet(viewsets.ModelViewSet):
queryset = FoodHasIngredient.objects.all()
serializer_class = FoodHasIngredientSerializer
class IngredientViewSet(viewsets.ModelViewSet):
queryset = Ingredient.objects.all()
serializer_class = IngredientSerializer
class PermissionViewSet(viewsets.ModelViewSet):
queryset = Permission.objects.all()
serializer_class = PermissionSerializer
class RestaurantViewSet(viewsets.ModelViewSet):
queryset = Restaurant.objects.all()
serializer_class = RestaurantSerializer
class RoleViewSet(viewsets.ModelViewSet):
queryset = Role.objects.all()
serializer_class = RoleSerializer
class RoleHasPermissionViewSet(viewsets.ModelViewSet):
queryset = RoleHasPermission.objects.all()
serializer_class = RoleHasPermissionSerializer
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
class UserFollowsDietViewSet(viewsets.ModelViewSet):
queryset = UserFollowsDiet.objects.all()
serializer_class = UserFollowsDietSerializer
class UserProhibitsIngredientViewSet(viewsets.ModelViewSet):
queryset = UserProhibitsIngredient.objects.all()
serializer_class = UserProhibitsIngredientSerializer
class UserRatesDrinkViewSet(viewsets.ModelViewSet):
queryset = UserRatesDrink.objects.all()
serializer_class = UserRatesDrinkSerializer
class UserRatesFoodViewSet(viewsets.ModelViewSet):
queryset = UserRatesFood.objects.all()
serializer_class = UserRatesFoodSerializer
class UserRatesRestaurantViewSet(viewsets.ModelViewSet):
queryset = UserRatesRestaurant.objects.all()
serializer_class = UserRatesRestaurantSerializer
from rest_framework.views import APIView, Response
class Signup(APIView):
def get(self, request, format=None):
serializer = User.objects.all()
return Response(serializer.data, status=status.HTTP_201_CREATED)
def post(self, request, format=None):
serializer = UserSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@classmethod
def get_extra_actions(cls):
return []

129
UI/Database API/hyrieus/flavoursAPI/settings.py

@ -0,0 +1,129 @@
"""
Django settings for flavoursAPI project.
Generated by 'django-admin startproject' using Django 2.1.4.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'pz6p6wc1%%0c&dc8lutf)k5sba*4sxnv3ooynci0mcv-l-p_j8'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['83.212.109.171']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'flavoursAPI.hyrieus',
'rest_framework',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'flavoursAPI.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'flavoursAPI.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'flavours_without_borders',
'USER': 'flavoursUser',
'PASSWORD': 'flavours13',
'HOST': '83.212.109.171',
# 'HOST': '127.0.0.1',
'PORT': '',
},
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
SILENCED_SYSTEM_CHECKS = ['mysql.E001']

24
UI/Database API/hyrieus/flavoursAPI/urls.py

@ -0,0 +1,24 @@
"""flavoursAPI URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.conf import settings
from django.conf.urls import url, include
urlpatterns = [
path('admin/', admin.site.urls),
url(r'^api/', include('flavoursAPI.hyrieus.urls')),
]

16
UI/Database API/hyrieus/flavoursAPI/wsgi.py

@ -0,0 +1,16 @@
"""
WSGI config for flavoursAPI project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'flavoursAPI.settings')
application = get_wsgi_application()

15
UI/Database API/hyrieus/manage.py

@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'flavoursAPI.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
Loading…
Cancel
Save