pylinting

parent e7107bd2
This diff is collapsed.
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import CourseComment,DocumentComment,Course,User,Teacher,Document,CourseLike,DocumentLike
from .models import CourseComment, DocumentComment, Course, User, Teacher, Document, CourseLike, DocumentLike
# Register your models here.
admin.site.register(DocumentComment)
......
......@@ -14,15 +14,15 @@ class PostCourseCommentForm(forms.ModelForm):
class PostDocumentForm(forms.ModelForm):
class Meta:
model = Document
fields=['name','course','file','description','type','documentDate','correction']
fields = ['name', 'course', 'file', 'description', 'type', 'documentDate', 'correction']
class PostCourseForm(forms.ModelForm):
class Meta:
model = Course
fields=['name','type',"year",'description']
fields = ['name', 'type', "year", 'description']
class PostTeacherForm(forms.ModelForm):
class Meta:
model = Teacher
fields = ['firstName','lastName','email','department','office']
fields = ['firstName', 'lastName', 'email', 'department', 'office']
\ No newline at end of file
from django.shortcuts import redirect
from django.http import HttpResponseRedirect
import requests
import time
import datetime
from .models import User
from django.core import serializers
class CGUMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if request.path in ['/legal','/accept_CGU', '/auth/login']:
if request.path in ['/legal', '/accept_CGU', '/auth/login']:
# Middleware default allowed pages
return self.get_response(request)
if request.user.is_anonymous:
......@@ -20,8 +14,7 @@ class CGUMiddleware:
if request.user.hasAcceptedCGU:
# Let people go if they accepted CGU
return self.get_response(request)
else:
return HttpResponseRedirect('/legal')
return HttpResponseRedirect('/legal')
class MessagesMiddleware:
def __init__(self, get_response):
......@@ -29,4 +22,4 @@ class MessagesMiddleware:
def __call__(self, request):
request.messages = []
return self.get_response(request)
\ No newline at end of file
return self.get_response(request)
......@@ -7,19 +7,19 @@ class Course(models.Model):
year = models.CharField(
max_length=2,
choices=(
('1A','1A'),
('2A','2A'),
('3A','3A'),
('1A', '1A'),
('2A', '2A'),
('3A', '3A'),
),
null=True,
null=True,
)
description = models.CharField(max_length=10000,null=True,blank=True)
teachers = models.ManyToManyField('Teacher',blank=True)
description = models.CharField(max_length=10000, null=True, blank=True)
teachers = models.ManyToManyField('Teacher', blank=True)
type = models.CharField(
max_length=50,
choices=(
('Tronc commun','Tronc commun'),
('Electif','Electif'),
('Tronc commun', 'Tronc commun'),
('Electif', 'Electif'),
),
null=True,
)
......@@ -31,21 +31,22 @@ class Course(models.Model):
class Document(models.Model):
name = models.CharField(max_length=200)
documentDate = models.DateField()
description = models.CharField(max_length=10000,null=False,blank=True)
description = models.CharField(max_length=10000, null=False, blank=True)
isAccepted = models.BooleanField(default=False)
user = models.ForeignKey('User', on_delete=models.SET_NULL,null=True,blank=True)
course = models.ForeignKey('Course',on_delete=models.SET_NULL,null=True,blank=True)
user = models.ForeignKey('User', on_delete=models.SET_NULL, null=True, blank=True)
course = models.ForeignKey('Course', on_delete=models.SET_NULL, null=True, blank=True)
file = models.FileField(upload_to='')
correction = models.FileField(upload_to='corrections/', blank=True, null=True)
type = models.CharField(
max_length=50,
choices=(
('Annale','Annale'),
('Fiche','Fiche'),
('Poly de cours','Poly de cours'),
('Annale', 'Annale'),
('Fiche', 'Fiche'),
('Poly de cours', 'Poly de cours'),
('Notes de cours', 'Notes de cours'),
),
null=True)
null=True
)
def __str__(self):
return self.name
......@@ -55,8 +56,8 @@ class DocumentComment(models.Model):
content = models.CharField(max_length=10000)
commentDate = models.DateTimeField()
isModerated = models.BooleanField(default=False)
user = models.ForeignKey('User',on_delete=models.CASCADE,null=True,blank=True)
document = models.ForeignKey('Document',on_delete=models.CASCADE)
user = models.ForeignKey('User', on_delete=models.CASCADE, null=True, blank=True)
document = models.ForeignKey('Document', on_delete=models.CASCADE)
def __str__(self):
return str(self.commentDate)
......@@ -66,21 +67,21 @@ class CourseComment(models.Model):
content = models.CharField(max_length=10000)
commentDate = models.DateTimeField()
isModerated = models.BooleanField(default=False)
user = models.ForeignKey('User',on_delete=models.CASCADE,null=True,blank=True)
course = models.ForeignKey('Course',on_delete=models.CASCADE)
user = models.ForeignKey('User', on_delete=models.CASCADE, null=True, blank=True)
course = models.ForeignKey('Course', on_delete=models.CASCADE)
def __str__(self):
return str(self.commentDate)
class Teacher(models.Model):
firstName = models.CharField(max_length=50,null=True,blank=True)
firstName = models.CharField(max_length=50, null=True, blank=True)
lastName = models.CharField(max_length=50)
email = models.EmailField(max_length=100,null=True,blank=True)
department = models.CharField(max_length=50,null=True,blank=True)
office = models.CharField(max_length=50,null=True,blank=True)
email = models.EmailField(max_length=100, null=True, blank=True)
department = models.CharField(max_length=50, null=True, blank=True)
office = models.CharField(max_length=50, null=True, blank=True)
isAccepted = models.BooleanField(default=False)
def __str__(self):
return self.lastName
......@@ -115,16 +116,16 @@ User._meta.get_field('last_login').verbose_name = "Dernière connexion"
User._meta.get_field('date_joined').verbose_name = "Première connexion"
class CourseLike(models.Model):
user = models.ForeignKey('User',on_delete=models.CASCADE)
course = models.ForeignKey('Course',on_delete=models.CASCADE)
user = models.ForeignKey('User', on_delete=models.CASCADE)
course = models.ForeignKey('Course', on_delete=models.CASCADE)
def __str__(self):
return str(self.user) + " aime " + str(self.course)
class DocumentLike(models.Model):
user = models.ForeignKey('User',on_delete=models.CASCADE)
document = models.ForeignKey('Document',on_delete=models.CASCADE)
user = models.ForeignKey('User', on_delete=models.CASCADE)
document = models.ForeignKey('Document', on_delete=models.CASCADE)
def __str__(self):
return str(self.user) + " aime " + str(self.document)
\ No newline at end of file
return str(self.user) + " aime " + str(self.document)
from core.models import User
import requests
from core.models import User
def find_or_create_user(access_token, access_token_payload):
......@@ -25,4 +25,3 @@ def find_or_create_user(access_token, access_token_payload):
user.is_superuser = True
user.save()
return user
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.
from django.urls import path, re_path
from django.urls import path
from . import views
......@@ -40,4 +40,4 @@ urlpatterns = [
# Like
path("like/<type>/<int:id>", views.like, name="like"),
path("dislike/<type>/<int:id>", views.dislike, name="dislike"),
]
\ No newline at end of file
]
......@@ -2,4 +2,4 @@ from core.models import Teacher, Course, Document, CourseComment, DocumentCommen
def count_to_moderate():
to_moderate_number = len(Course.objects.filter(isAccepted=False)) + len(Document.objects.filter(isAccepted=False)) + len(Teacher.objects.filter(isAccepted=False)) + len(CourseComment.objects.filter(isModerated=False)) + len(DocumentComment.objects.filter(isModerated=False))
return to_moderate_number
\ No newline at end of file
return to_moderate_number
This diff is collapsed.
......@@ -77,8 +77,9 @@ TEMPLATES = [
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',)
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
WSGI_APPLICATION = 'nofistv2.wsgi.application'
......@@ -148,7 +149,7 @@ SITE_ID = 1
# OAUTH
LOGIN_URL = reverse_lazy('oauth_vr:login')
LOGIN_REDIRECT_URL = reverse_lazy('core:home')
LOGOUT_REDIRECT_URL = 'https://auth.viarezo.fr/logout?%s' % urlencode({ 'redirect_logout': domain })
LOGOUT_REDIRECT_URL = 'https://auth.viarezo.fr/logout?%s' % urlencode({'redirect_logout': domain})
OAUTH_CLIENT_ID = client_id
OAUTH_CLIENT_SECRET = client_secret
......@@ -165,4 +166,4 @@ if environment == "production":
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
elif environment == "development":
DEBUG = True
\ No newline at end of file
DEBUG = True
......@@ -7,11 +7,12 @@ For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os, sys
import os
import sys
from django.core.wsgi import get_wsgi_application
sys.path.append('/var/www/nofistv2')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nofistv2.settings")
......
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