From 7b92f11554363d8065fdf1c05e478f094f0996d6 Mon Sep 17 00:00:00 2001 From: Daniel Xenes Date: Fri, 10 Feb 2023 14:51:31 -0500 Subject: [PATCH] bug fix --- neuvue_project/dashboard/views.py | 18 ++++++++++-------- neuvue_project/neuvue/settings.py | 6 +++--- neuvue_project/neuvueDB.sqlite3 | Bin 389120 -> 389120 bytes neuvue_project/workspace/views/tools.py | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/neuvue_project/dashboard/views.py b/neuvue_project/dashboard/views.py index 7867388..3879791 100644 --- a/neuvue_project/dashboard/views.py +++ b/neuvue_project/dashboard/views.py @@ -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()]) @@ -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") @@ -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 diff --git a/neuvue_project/neuvue/settings.py b/neuvue_project/neuvue/settings.py index cc60bb2..b994442 100644 --- a/neuvue_project/neuvue/settings.py +++ b/neuvue_project/neuvue/settings.py @@ -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", @@ -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" \ No newline at end of file diff --git a/neuvue_project/neuvueDB.sqlite3 b/neuvue_project/neuvueDB.sqlite3 index 4ed6d6e194f0db416780be2f936f7fac1ec430d0..b32f70f905e51a0f7bd97afda09020f42fe1f8a6 100644 GIT binary patch delta 1980 zcmah}d2AGA6rXR7-OjZiMJZM--D05_y6eo&)!lNqJ?KGOTFO>h!0mRoW$Tvh(mmR3 z<(T3{O+d22@k~?_JU}9@Ix3yj;@SbyGPj(DFC^oRPBec^a$o#+!1A--EmFW!3u!&Lfw%KXxAIDMYJl;*8xsp%$_ z#1Q~2tVyLZFBF?Ly)|*mEEZ-XFbY@0QFsLIhtI&r;5JwdPeKXKh1u!s&106r>sSo2 zHFo+!jlR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ip^B#PGC}%wCY+TCorUklmhmErd z7S3kjcoQd9a;{37!|HIkZBD_CJni@_Q80l)(a=jzFz>3!8}!I%MytcdL{Aq~labze~Z?A3}%H}flVIk1y4^{`-IC0moH$1$zttZpneK;Mm zcq74_e<;=w4R~8Kv4p=RHPFpPf?h7Zw@;|;N;Vzwx77^S21BuII5iO26HRsH8X}<) zP7EI6y)oC*QgX1bI>aURS?UwR@%U~rml0Bty0G_9v&gjy&p6|a1HH{PfvE3bq)`e> zAt|^kR2!%d`_f&$YJb3tv z+R-6Ohu%-(f37@uKmVUG-eq?=(Z~CVhDS?jyai)+&_MsC?gZ6fSYR(|SM z`t_=&7$*v;MYUM7MeT(swD^@~TXC@-AIA*i>_ha6`ag8fYj2Xh#4R<{gi4n*B_QuH zwF5N%lO|;;0amOGJA=Uv!wo|n`#Ec8-eZjPN$iZWsgN9_MhylA>yYF`!l~RWBw5PJ zyKJJ9+Q7Lea#I&8EGdv2=&O31BpU*~@G;RdpT#4!vl8_9rHp6`3INPVdP>v7s$ Wyx>5`%gAb6zTRJf?v|4UbAJPN{7LKp diff --git a/neuvue_project/workspace/views/tools.py b/neuvue_project/workspace/views/tools.py index 355821b..074e216 100644 --- a/neuvue_project/workspace/views/tools.py +++ b/neuvue_project/workspace/views/tools.py @@ -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: