Commit 3e3f466d authored by dennisjl's avatar dennisjl
Browse files

Merge branch 'refactoring' of into refactoring

parents c3b54b83 7b85472d
Pipeline #79923 passed with stage
in 1 minute and 8 seconds
......@@ -40,21 +40,6 @@
<li class="nav-item">
<a class="nav-link font-weight-light" href="{% url 'projects' %}">Projects</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
<div class="my-2 my-lg-0 mr-5">
......@@ -6,6 +6,8 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
LOGIN_PAGE = '/user/login'
def projects(request):
projects = Project.objects.all()
project_categories = ProjectCategory.objects.all()
......@@ -120,7 +122,7 @@ def project_view(request, project_id):
def isProjectOwner(user, project):
def is_project_owner(user, project):
return user == project.user.user
......@@ -131,7 +133,7 @@ def upload_file_to_task(request, project_id, task_id):
user_permissions = get_user_task_permissions(request.user, task)
accepted_task_offer = task.accepted_task_offer()
if user_permissions['modify'] or user_permissions['write'] or user_permissions['upload'] or isProjectOwner(request.user, project):
if user_permissions['modify'] or user_permissions['write'] or user_permissions['upload'] or is_project_owner(request.user, project):
if request.method == 'POST':
task_file_form = TaskFileForm(request.POST, request.FILES)
if task_file_form.is_valid():
......@@ -173,7 +175,7 @@ def upload_file_to_task(request, project_id, task_id):
'task_file_form': task_file_form,
return redirect('/user/login') # Redirects to /user/login
return redirect(LOGIN_PAGE) # Redirects to /user/login
def get_user_task_permissions(user, task):
......@@ -221,11 +223,11 @@ def task_view(request, project_id, task_id):
user_permissions = get_user_task_permissions(request.user, task)
if not user_permissions['read'] and not user_permissions['write'] and not user_permissions['modify'] and not user_permissions['owner'] and not user_permissions['view_task']:
return redirect('/user/login')
return redirect(LOGIN_PAGE)
if request.method == 'POST' and 'delivery' in request.POST:
if accepted_task_offer and accepted_task_offer.offerer == user.profile:
if (request.method == 'POST' and 'delivery' in request.POST and
accepted_task_offer and accepted_task_offer.offerer == user.profile):
deliver_form = DeliveryForm(request.POST, request.FILES)
if deliver_form.is_valid():
delivery =
......@@ -322,7 +324,7 @@ def task_view(request, project_id, task_id):
'per': per
return redirect('/user/login')
return redirect(LOGIN_PAGE)
def task_permissions(request, project_id, task_id):
Supports Markdown
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