Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dxenes1 committed Feb 10, 2023
1 parent d59a692 commit 7b92f11
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
18 changes: 10 additions & 8 deletions neuvue_project/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ def _get_status_count(task_df, status):
class DashboardView(View, LoginRequiredMixin):
def get(self, request, *args, **kwargs):
peak_admin = request.user.groups.filter(name=settings.PEAK_ADMIN).exists()
if not request.user.is_staff and not peak_admin:
if not (request.user.is_staff or peak_admin):
return redirect(reverse("index"))

Namespaces = apps.get_model("workspace", "Namespace")
context = {}
if peak_admin:
namespace = Namespaces.objects.filter(namespace=settings.PEAK_NAMESPACE).first().display_name
context["all_groups"] = [settings.PEAK_COHORT]
context["all_namespaces"] = [settings.PEAK_NAMESPACE]
context["all_namespaces"] = [namespace]
context["all_users"] = _get_users_from_group(settings.PEAK_COHORT)
else:
context["all_groups"] = sorted([x.name for x in Group.objects.all()])
Expand Down Expand Up @@ -84,10 +85,10 @@ def post(self, request, *args, **kwargs):
class DashboardNamespaceView(View, LoginRequiredMixin):
def get(self, request, group=None, namespace=None, *args, **kwargs):
peak_admin = request.user.groups.filter(name=settings.PEAK_ADMIN).exists()
if not request.user.is_staff and not peak_admin:
if not (request.user.is_staff or peak_admin):
return redirect(reverse("index"))

if namespace != settings.PEAK_NAMESPACE:
if peak_admin and namespace != settings.PEAK_NAMESPACE:
return redirect(reverse("index"))

Namespaces = apps.get_model("workspace", "Namespace")
Expand Down Expand Up @@ -183,16 +184,17 @@ def _generate_table_and_counts(self, namespace: str, users: List):
class DashboardUserView(View, LoginRequiredMixin):
def get(self, request, username=None, filter=None, *args, **kwargs):
peak_admin = request.user.groups.filter(name=settings.PEAK_ADMIN).exists()
if not request.user.is_staff and not peak_admin:
if not (request.user.is_staff or peak_admin):
return redirect(reverse("index"))

if username not in _get_users_from_group(settings.PEAK_COHORT):
if peak_admin and username not in _get_users_from_group(settings.PEAK_COHORT):
return redirect(reverse("index"))

context = {}
if peak_admin:
table, counts = self._generate_table_and_counts(username, settings.PEAK_NAMESPACE)
else:
table, counts = self._generate_table_and_counts(username, settings.PEAK_NAMESPACE)
table, counts = self._generate_table_and_counts(username)

context["username"] = username
context["table"] = table
Expand Down
6 changes: 3 additions & 3 deletions neuvue_project/neuvue/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = [
"app.neuvue.io",
Expand Down Expand Up @@ -240,6 +240,6 @@
STATIC_NG_FILES = os.listdir(os.path.join(BASE_DIR, "workspace", "static", "workspace"))

# PEAK EXPERIMENT
PEAK_ADMIN = "AGTExpAdmins"
PEAK_COHORT = "PeakCohort"
PEAK_ADMIN = "PeakAdmins"
PEAK_COHORT = "PeakParticipants"
PEAK_NAMESPACE = "peakExtension"
Binary file modified neuvue_project/neuvueDB.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion neuvue_project/workspace/views/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get(self, request, task_id=None, *args, **kwargs):
logging.warning(f"Unauthorized requests from {request.user}.")
return redirect(reverse("index"))

if request.user.username in _get_users_from_group(settings.PEAK_NAMESPACE):
if request.user.username in _get_users_from_group(settings.PEAK_COHORT):
return redirect(reverse("index"))

if task_id is None:
Expand Down

0 comments on commit 7b92f11

Please sign in to comment.