Commit baab2415 authored by Floréal Cabanettes's avatar Floréal Cabanettes

Fix code to be more PEP8

parent 5d959d7d
......@@ -3,10 +3,25 @@ import os, errno, re, json
from django.utils.translation import ugettext as _
from pywebcooking import settings
from main.controllers import CRecipe, CIngredientGroup, CInstruction, CEquipment, CProposal
from main.models import UserProfile, Category, Recipe, IngredientGroup, EquipmentInRecipe, Instruction, Proposal, \
MediaInRecipe
from main.functions import Functions as MainFunctions
# Controllers:
from main.controllers.C_Recipe import CRecipe
from main.controllers.C_IngredientGroup import CIngredientGroup
from main.controllers.C_Instruction import CInstruction
from main.controllers.C_Equipment import CEquipment
from main.controllers.C_Proposal import CProposal
# Models:
from main.models.UserProfile import UserProfile
from main.models.Category import Category
from main.models.Recipe import Recipe
from main.models.IngredientGroup import IngredientGroup
from main.models.EquipmentInRecipe import EquipmentInRecipe
from main.models.Instruction import Instruction
from main.models.Proposal import Proposal
from main.models.MediaInRecipe import MediaInRecipe
from main.functions.functions import Functions as MainFunctions
# import the logging library
import logging
......
......@@ -2,7 +2,7 @@ from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from main.models import Category
from main.models.Category import Category
class Categories(APIView):
......
......@@ -7,8 +7,9 @@ from api.exceptions import RecipeNotFound
from api.functions import Functions
from main.controllers import CRecipe
from main.models import Recipe, UserProfile
from main.controllers.C_Recipe import CRecipe
from main.models.Recipe import Recipe
from main.models.UserProfile import UserProfile
from django.utils.translation import ugettext as _
......
......@@ -5,7 +5,7 @@ from rest_framework.parsers import MultiPartParser, FormParser
from django.core.exceptions import ObjectDoesNotExist
from api.exceptions import RecipeNotFound
from main.controllers import CRecipe
from main.controllers.C_Recipe import CRecipe
class RecipeBySlug(APIView):
......
......@@ -7,8 +7,8 @@ from django.utils.translation import ugettext as _
from api.functions import Functions
from main.controllers import CRecipe
from main.models import UserProfile
from main.controllers.C_Recipe import CRecipe
from main.models.UserProfile import UserProfile
class RecipeList(APIView):
......
......@@ -2,7 +2,9 @@ from django.contrib import admin
# Register your models here.
from .models import Category, Recipe, UserProfile
from .models.Category import Category
from .models.Recipe import Recipe
from .models.UserProfile import UserProfile
class CategoryAdmin(admin.ModelAdmin):
......@@ -15,9 +17,11 @@ class RecipeAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False
class UserProfileAdmin(admin.ModelAdmin):
fields = ["user", "url"]
admin.site.register(Category, CategoryAdmin)
admin.site.register(Recipe, RecipeAdmin)
admin.site.register(UserProfile, UserProfileAdmin)
from main.models import Comment, Recipe, UserProfile
from main.models.Comment import Comment
from main.models.Recipe import Recipe
from main.models.UserProfile import UserProfile
from main.functions.exceptions import RequiredParameterException
......
from main.models import Equipment, Recipe, EquipmentInRecipe
from main.models.Equipment import Equipment
from main.models.Recipe import Recipe
from main.models.EquipmentInRecipe import EquipmentInRecipe
from main.functions.exceptions import RequiredParameterException, MissingKeyException, UnknownKeyException
......
import django
from main.models import IngredientGroup, IngredientInGroup, Ingredient, Recipe
from main.models.IngredientGroup import IngredientGroup
from main.models.IngredientInGroup import IngredientInGroup
from main.models.Ingredient import Ingredient
from main.models.Recipe import Recipe
from main.functions import Functions
from main.functions.functions import Functions
from main.functions.exceptions import RequiredParameterException, MissingKeyException
......
from main.models import Recipe, Instruction
from main.models.Recipe import Recipe
from main.models.Instruction import Instruction
from main.functions.exceptions import RequiredParameterException
from main.functions import Functions
from main.functions.functions import Functions
class CInstruction:
......
from main.models import Proposal, Recipe
from main.models.Proposal import Proposal
from main.models.Recipe import Recipe
from main.functions.exceptions import RequiredParameterException, MissingKeyException, UnknownKeyException
from main.functions import Functions
from main.functions.functions import Functions
class CProposal:
......
......@@ -5,7 +5,12 @@ import re
from pywebcooking.settings import MEDIA_ROOT
from main.models import Recipe, Category, IngredientInGroup, UserProfile, MediaInRecipe
from main.models.Recipe import Recipe
from main.models.Category import Category
from main.models.IngredientInGroup import IngredientInGroup
from main.models.UserProfile import UserProfile
from main.models.MediaInRecipe import MediaInRecipe
from django.contrib.auth.models import User
from main.functions.exceptions import RequiredParameterException, BadParameterException
......
from .C_Recipe import CRecipe
from .C_IngredientGroup import CIngredientGroup
from .C_Instruction import CInstruction
from .C_Equipment import CEquipment
from .C_Proposal import CProposal
from .C_Comment import CComment
from .exceptions import *
from .functions import Functions
\ No newline at end of file
from django.db import models
from .Equipment import Equipment
from .Recipe import Recipe
class EquipmentInRecipe(models.Model):
equipment = models.ForeignKey(Equipment, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
recipe = models.ForeignKey("Recipe", on_delete=models.CASCADE)
quantity = models.IntegerField(null=True)
is_comment = models.BooleanField(default=False)
nb = models.IntegerField()
......
......@@ -5,6 +5,7 @@ from django.utils.translation import ugettext as _, pgettext as __
from .Category import Category
from .Equipment import Equipment
from .UserProfile import UserProfile
from .EquipmentInRecipe import EquipmentInRecipe
from django.conf import settings
from django.db.models.signals import post_delete
......
from .Recipe import Recipe
from .Group import Group
from .Category import Category
from .Ingredient import Ingredient
from .IngredientGroup import IngredientGroup
from .IngredientInGroup import IngredientInGroup
from .Instruction import Instruction
from .Proposal import Proposal
from .Comment import Comment
from .Equipment import Equipment
from .EquipmentInRecipe import EquipmentInRecipe
from .UserProfile import UserProfile
from .MediaInRecipe import MediaInRecipe
\ No newline at end of file
......@@ -4,7 +4,10 @@ from django.db import transaction
from main.tests import TModels
from main.controllers import CIngredientGroup, CInstruction, CProposal, CEquipment
from main.controllers.C_IngredientGroup import CIngredientGroup
from main.controllers.C_Instruction import CInstruction
from main.controllers.C_Proposal import CProposal
from main.controllers.C_Equipment import CEquipment
class TDuplicates(TestCase):
......
from django.test import TestCase
from main.models import Category, Recipe, IngredientGroup, IngredientInGroup, Instruction, Equipment, \
EquipmentInRecipe, Proposal, Comment, UserProfile
# Models:
from main.models.Category import Category
from main.models.Recipe import Recipe
from main.models.IngredientGroup import IngredientGroup
from main.models.IngredientInGroup import IngredientInGroup
from main.models.Instruction import Instruction
from main.models.Equipment import Equipment
from main.models.EquipmentInRecipe import EquipmentInRecipe
from main.models.Proposal import Proposal
from main.models.Comment import Comment
from main.models.UserProfile import UserProfile
from django.contrib.auth.models import User
from main.controllers import CRecipe, CIngredientGroup, CInstruction, CEquipment, CProposal, CComment
# Controllers:
from main.controllers.C_Recipe import CRecipe
from main.controllers.C_IngredientGroup import CIngredientGroup
from main.controllers.C_Instruction import CInstruction
from main.controllers.C_Equipment import CEquipment
from main.controllers.C_Proposal import CProposal
from main.controllers.C_Comment import CComment
from main.functions.exceptions import *
......
from main.models import Category
from main.models.Category import Category
class GenericView:
......
......@@ -3,7 +3,10 @@ from django.shortcuts import render, redirect
from pywebcooking import settings
from django.utils.translation import ugettext as _
from pywebcooking.settings import MEDIA_ROOT
from main.models import Recipe, Comment
from main.models.Recipe import Recipe
from main.models.Comment import Comment
from django.contrib.auth.models import User
from django_gravatar.helpers import get_gravatar_url
......
from django.views.generic import View
from django.shortcuts import render, redirect
from pywebcooking import settings
from main.models import Recipe, Category
from main.models.Recipe import Recipe
from main.models.Category import Category
from django_gravatar.helpers import get_gravatar_url
from django.utils.translation import ugettext as _
......
from django.views.generic import View
from django.http import JsonResponse, Http404
from main.models import Recipe
from main.models.Recipe import Recipe
class RecipesChangeView(View):
......
......@@ -4,7 +4,10 @@ from django.shortcuts import render, redirect, reverse, HttpResponseRedirect
from pywebcooking import settings
from django.utils.translation import ugettext as _
from pywebcooking.settings import MEDIA_ROOT, LOCALE
from main.models import Recipe, UserProfile
from main.models.Recipe import Recipe
from main.models.UserProfile import UserProfile
from main.config import RecipeConfig
from django_gravatar.helpers import get_gravatar_url
from .GenericView import GenericView
......
from main.models import Category
from main.models.Category import Category
from website.config import MainConfig
......
......@@ -10,7 +10,10 @@ from django_gravatar.helpers import get_gravatar_url
from pywebcooking.settings import MEDIA_ROOT, POSTS_PER_PAGE, SITE_NAME
from main.config import RecipeConfig
from main.models import Recipe, Category, UserProfile
from main.models.Recipe import Recipe
from main.models.Category import Category
from main.models.UserProfile import UserProfile
class IndexView(TemplateView):
......
......@@ -8,8 +8,11 @@ from django_gravatar.helpers import get_gravatar_url
from website.forms import CommentForm, CommentFormAuthenticated
from main.controllers import CRecipe, CComment
from main.models import UserProfile
from main.controllers.C_Recipe import CRecipe
from main.controllers.C_Comment import CComment
from main.models.UserProfile import UserProfile
from pywebcooking.settings import SITE_NAME
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment