Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sg and cw access query changed #17

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions supervisor/methods.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from supervisor.models import TA
from studentportal.models import Project
from supervisor.decorators import supervisor_logged_in
from credentials import SG_USERS, CW_USERS, FULL_USERS
Expand All @@ -6,12 +7,15 @@
@supervisor_logged_in
def filtered_projects(request, **kwargs):
queryset = None
if request.user.email in FULL_USERS:
user=TA.objects.filter(email=request.user.email).first()
if user==None:
queryset = Project.objects.none()
elif user.sg_access and user.cw_access:
queryset = Project.objects.filter(**kwargs)
elif request.user.email in SG_USERS:
elif user.sg_access:
queryset = Project.objects.filter(category__name='SG', **kwargs)
elif request.user.email in CW_USERS:
elif user.cw_access:
queryset = Project.objects.filter(category__name='CW', **kwargs)
else:
queryset = Project.objects.filter(**kwargs)
queryset = Project.objects.none()
return queryset
23 changes: 23 additions & 0 deletions supervisor/migrations/0002_auto_20210630_0316.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.0.8 on 2021-06-30 03:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('supervisor', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='ta',
name='cw_access',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='ta',
name='sg_access',
field=models.BooleanField(default=False),
),
]
2 changes: 2 additions & 0 deletions supervisor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def get_priority(self):
class TA(models.Model):
email = models.CharField(max_length=100)
instructor = models.BooleanField(default=False)
sg_access = models.BooleanField(default=False)
cw_access = models.BooleanField(default=False)


class Diff(models.Model):
Expand Down