Commit 70cd185c authored by Martin Lehoux's avatar Martin Lehoux

Merge branch 'dev' into 'master'

Dev

See merge request !34
parents cfeefbfa 07d27767
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
......@@ -38,14 +38,16 @@
<i class="ui database icon"></i>
Tes données
</h2>
<div class="ui relaxed divided list">
<table class="ui very basic collapsing celled table">
<tbody>
{% for field, value in data %}
<div class="item content">
<p class="header">{{ field }}</p>
<p class="description">{{ value }}</p>
</div>
<tr>
<td><p class="header">{{ field }}</p></td>
<td><p class="description">{% if value == True %}<i class="ui green check circle icon"></i>{% elif value == False %}<i class="ui red close icon"></i>{% else %}{{ value }}{% endif %}</p></td>
</tr>
{% endfor %}
</div>
</tbody>
</table>
<div class="ui center aligned container">
<button onclick="$('.ui.modal').modal('show')" class="ui red button">Supprimer mon compte</button>
</div>
......
......@@ -10,6 +10,9 @@
<span id="stars">{{ course.like_list|length }}</span>
</div>
</div>
<button id="like" class="ui green right floated icon button"> <i class="thumbs up icon"></i> </button>
<button id="dislike" class="ui red right floated icon button"> <i class="thumbs down icon"></i> </button>
<button id="load" class="ui loading right floated button"> . </button>
</div>
</div>
<div class="content">
......@@ -26,11 +29,6 @@
<p class="ui red label">{{course.year}}</p>
<p class="ui {% if course.type == 'Electif' %}grey{% else %}teal{% endif %} label">{{ course.type }}</p>
</div>
<div class="ui one bottom attached buttons">
<button id="like" class="ui green basic labeled icon fluid button"> <i class="thumbs up icon"></i> J'aime ce cours</button>
<button id="dislike" class="ui red basic labeled icon fluid button"> <i class="thumbs down icon"></i> Je n'aime plus ce cours</button>
<button id="load" class="ui loading fluid button">Loading...</button>
</div>
</div>
</div>
......
......@@ -10,6 +10,9 @@
<span id="stars">{{ document.like_list|length }}</span>
</div>
</div>
<button id="like" class="ui green right floated icon button"> <i class="thumbs up icon"></i></a>
<button id="dislike" class="ui red right floated icon button"> <i class="thumbs down icon"></i></a>
<button id="load" class="ui loading right floated button">.</button>
</div>
{% if document.course.pk != Null %}<div class="meta"><a href="{% url 'core:get_course' document.course.pk %}">{{document.course}}</a></div>{% endif %}
</div>
......@@ -20,12 +23,9 @@
<p class="ui {% if document.type == 'Annale' %}red{% else %}blue{% endif %} label">{{ document.type }}</p>
<p class="ui green label">{{document.documentDate.year}}</p>
</div>
<div class="ui {% if document.type == "Annale" %}three{% else %}two{% endif %} bottom attached buttons">
<div class="ui {% if document.type == "Annale" %}two{% else %}one{% endif %} bottom attached buttons">
<a href="{% url 'core:download_document' document.id %}" class="ui blue basic labeled icon fluid button" target="_new"> <i class="cloud download icon"></i> Sujet</a>
{% if document.type == "Annale" %}<a href="{% url 'core:download_correction' document.id %}" class="ui blue basic labeled icon fluid button" target="_new"> <i class="edit icon"></i> Correction </a>{% endif %}
<button id="like" class="ui green basic icon button"> <i class="thumbs up icon"></i></a>
<button id="dislike" class="ui red basic icon button"> <i class="thumbs down icon"></i></a>
<button id="load" class="ui loading fluid button">Loading...</button>
</div>
</div>
</div>
......
......@@ -49,7 +49,7 @@
</a>
<div class="right menu">
<div class="item">
{% if to_moderate_number != 0 %}
{% if to_moderate_number != 0 and user.is_staff %}
<a class="ui red label" href="{% url 'core:moderation' %}">
<i class="ui bell icon"></i>
{{ to_moderate_number }}
......
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