Skip to content

Commit

Permalink
noPermission
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadjer711 committed Jul 4, 2020
1 parent 24cdb5b commit 9bbf243
Show file tree
Hide file tree
Showing 88 changed files with 78 additions and 12 deletions.
Binary file modified API/__pycache__/wsgi.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/config.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified article/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified article/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
7 changes: 6 additions & 1 deletion article/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.shortcuts import render
from django.template.loader import render_to_string

from django.contrib.auth.decorators import permission_required

from datetime import datetime
# Create your views here.
Expand All @@ -18,10 +19,11 @@
class ArticleViewSet(viewsets.ModelViewSet):
queryset = Article.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = ArticleSerializer


@action(methods=['post', 'get', 'put'], detail=False)
def ArticleAdd(self, request):

Expand Down Expand Up @@ -63,6 +65,7 @@ def ArticleAdd(self, request):
return Response(serializers.data, status=status.HTTP_201_CREATED)
return Response(serializers.errors, status=status.HTTP_400_BAD_REQUEST)


@action(methods=['put'], detail=True)
def ArticleSupprimer(self, request, pk=None):
try:
Expand All @@ -75,6 +78,7 @@ def ArticleSupprimer(self, request, pk=None):
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@action(methods=['put'], detail=True)
def ArticleValider(self, request, pk=None):
try:
Expand All @@ -87,6 +91,7 @@ def ArticleValider(self, request, pk=None):
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@action(methods=['get'], detail=False)
def ArticleAll(self, request):
if(request.method == "GET"):
Expand Down
Binary file modified commentaire/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified commentaire/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion commentaire/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from rest_framework.response import Response
from rest_framework.decorators import api_view, action

from django.contrib.auth.decorators import permission_required

from rest_framework import viewsets, permissions

Expand Down Expand Up @@ -32,6 +32,7 @@ def show_list(self, request):
return Response(serializers.data, status=status.HTTP_201_CREATED)
return Response(serializers.errors, status=status.HTTP_400_BAD_REQUEST)


@action(methods=['put'], detail=True)
def CommentSupprimer(self, request, pk=None):
try:
Expand Down
Binary file modified coronawatch/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified coronawatch/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified coronawatch/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified coronawatch/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified coronawatch/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified coronawatch/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/views.cpython-38.pyc
Binary file not shown.
3 changes: 1 addition & 2 deletions customauth/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin
from .models import *
from django.contrib.auth.models import Group


# Register your models here.
3 changes: 3 additions & 0 deletions customauth/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

class AuthConfig(AppConfig):
name = 'customauth'
def ready(self):
from customauth.group import group_perms
group_perms()
15 changes: 15 additions & 0 deletions customauth/group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.contrib.auth.models import Group


def group_perms():
editorPerm=['article.add_article', 'article.view_article']
moderatorPerm=['article.delete_article', 'article.change_article']
healthagentPerm=[]
EDITOR = Group.objects.create(name='Editor')
MODERATOR = Group.objects.create(name='Moderator')
HEALTH_AGENT = Group.objects.create(name='Health Agent')

EDITOR.permissions.set(editorPerm)
MODERATOR.permissions.set(moderatorPerm)
HEALTH_AGENT.permissions.set(healthagentPerm)

Binary file modified customauth/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
25 changes: 24 additions & 1 deletion customauth/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from django.db import models
from django.dispatch import receiver
from django.db.models.signals import post_save

from django.contrib.auth.models import (
AbstractUser
)
# Create your models here.

editorPerm=[('article.add_article', 'article.view_article')]
moderatorPerm=['article.delete_article', 'article.change_article']
healthagentPerm=[]

class User(AbstractUser):
"""customauth/login-related fields"""
ROLE = (
Expand All @@ -19,4 +27,19 @@ class User(AbstractUser):
REQUIRED_FIELDS = ['role']

def __str__(self):
return super().__str__()
return super().__str__()


@receiver(post_save, sender=User)
def define_permission(sender, **kwargs):
if User.objects.last().role == 'editor':
print("editor saved")

elif User.objects.last().role == 'moderator':
print("moderator saved")
elif User.objects.last().role == 'health agent':
print("health agent saved")
elif User.objects.last().role == 'final user':
print("final user saved")
else:
print("error in role model")
Binary file modified map/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified map/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified map/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
10 changes: 7 additions & 3 deletions map/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from rest_framework.response import Response
from datetime import datetime

from django.contrib.auth.decorators import permission_required
# Create your views here.


class RegionViewSet(viewsets.ModelViewSet):
queryset = Region.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = RegionSerializer

Expand All @@ -28,6 +29,7 @@ def get(self, request, pk=None):
serializer = RegionSerializer(queryset)
return Response(serializer.data)


@action(methods=['put'], detail=True)
def updateRegion(self, request, pk=None):
try:
Expand All @@ -44,10 +46,11 @@ def updateRegion(self, request, pk=None):
class InfoRegionViewSet(viewsets.ModelViewSet):
queryset = HistoriqueRegion.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = InfoRegionSerializer


@action(methods=['put'], detail=True)
def rejeter(self, request, pk=None):
try:
Expand All @@ -60,6 +63,7 @@ def rejeter(self, request, pk=None):
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@action(methods=['put'], detail=True)
def valider(self, request, pk=None):

Expand All @@ -83,7 +87,7 @@ def get(self, request, pk=None):
class CentreReceptionViewSet(viewsets.ModelViewSet):
queryset = CentreReception.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = CentreReceptionSerializer

Expand Down
Binary file added media/acceuil2_TS2zouF.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/acceuil2_W7EEuXs.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/edit.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified report/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified report/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified report/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified report/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified report/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified report/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified report/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion report/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class CasSignaleeViewSet(viewsets.ModelViewSet):
queryset = CasSignalee.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = CasSignalerSerializer

Expand Down
Binary file modified robot/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified robot/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified robot/__pycache__/apps.cpython-38.pyc
Binary file not shown.
Binary file modified robot/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified robot/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified robot/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified robot/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified robot/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file modified robot/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion robot/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class VeilleViewSet(viewsets.ModelViewSet):
queryset = Veille.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = VeilleSerializer
url = "http://news.google.com/news?q=covid-19&hl=ar-DZ&sort=date&gl=DZ&num=100&output=rss"
Expand Down
Binary file modified scraper/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified scraper/__pycache__/googleSearchScrapping.cpython-38.pyc
Binary file not shown.
Binary file modified scraper/__pycache__/twitterScrapping.cpython-38.pyc
Binary file not shown.
Binary file modified scraper/__pycache__/updater.cpython-38.pyc
Binary file not shown.
Binary file modified scraper/__pycache__/youtubeScraper.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified videos/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified videos/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified videos/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified videos/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified videos/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified videos/__pycache__/views.cpython-38.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions videos/migrations/0003_remove_videointernaut_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.0.4 on 2020-07-04 14:19

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('videos', '0002_videointernaut_owner'),
]

operations = [
migrations.RemoveField(
model_name='videointernaut',
name='description',
),
]
Binary file modified videos/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file modified videos/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion videos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ class VideoInternaut(models.Model):
vu = models.BooleanField(default=False)
date = models.DateTimeField(auto_now_add=True)
titre = models.CharField(max_length=20)
description = models.TextField()
video = models.FileField()
2 changes: 1 addition & 1 deletion videos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class VideoViewSet(viewsets.ModelViewSet):
queryset = VideoInternaut.objects.all()
permission_classes = [
permissions.IsAuthenticatedOrReadOnly
permissions.AllowAny
]
serializer_class = VideoSerializer

Expand Down

0 comments on commit 9bbf243

Please sign in to comment.