Commit a61943b59f3b6620c27b8e5b1aff3b1163c2627d
1 parent
91232ca8
Exists in
dev
Reworking Unit-board rights and renaming properly his role name in multiple files
Showing
14 changed files
with
38 additions
and
36 deletions
Show diff stats
src/core/pyros_django/api/views.py
... | ... | @@ -48,7 +48,7 @@ class UserViewSet(viewsets.ModelViewSet): |
48 | 48 | user = self.request.user |
49 | 49 | user_role = str(UserLevel.objects.get( |
50 | 50 | priority=user.get_priority()).name) |
51 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
51 | + if user_role in ("Unit-PI", "Admin"): | |
52 | 52 | queryset = PyrosUser.objects.all().order_by("-created") |
53 | 53 | else: |
54 | 54 | sp_of_current_user = user.get_scientific_program() |
... | ... | @@ -86,7 +86,7 @@ class SequenceViewSet(viewsets.ModelViewSet): |
86 | 86 | user = self.request.user |
87 | 87 | user_role = str(UserLevel.objects.get( |
88 | 88 | priority=user.get_priority()).name) |
89 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
89 | + if user_role in ("Unit-PI", "Admin"): | |
90 | 90 | return Sequence.objects.all().order_by("-updated") |
91 | 91 | else: |
92 | 92 | return Sequence.objects.filter(pyros_user=user).order_by("-updated") |
... | ... | @@ -109,7 +109,7 @@ class ScientificProgramViewSet(viewsets.ModelViewSet): |
109 | 109 | user = self.request.user |
110 | 110 | user_role = str(UserLevel.objects.get( |
111 | 111 | priority=user.get_priority()).name) |
112 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
112 | + if user_role in ("Unit-PI", "Admin"): | |
113 | 113 | return ScientificProgram.objects.all().order_by("-updated") |
114 | 114 | else: |
115 | 115 | return user.get_scientific_program().order_by("-updated") |
... | ... | @@ -133,7 +133,7 @@ class SPPeriodViewSet(viewsets.ModelViewSet): |
133 | 133 | user = self.request.user |
134 | 134 | user_role = str(UserLevel.objects.get( |
135 | 135 | priority=user.get_priority()).name) |
136 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
136 | + if user_role in ("Unit-PI", "Admin"): | |
137 | 137 | return SP_Period.objects.all().order_by("-scientific_program") |
138 | 138 | else: |
139 | 139 | user_scientific_programs = user.get_scientific_program() |
... | ... | @@ -157,7 +157,7 @@ class FullSequenceViewSet(viewsets.ModelViewSet): |
157 | 157 | user = self.request.user |
158 | 158 | user_role = str(UserLevel.objects.get( |
159 | 159 | priority=user.get_priority()).name) |
160 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
160 | + if user_role in ("Unit-PI", "Admin"): | |
161 | 161 | return Sequence.objects.all().order_by("-updated") |
162 | 162 | else: |
163 | 163 | return Sequence.objects.filter(pyros_user=user).order_by("-updated") |
... | ... | @@ -194,7 +194,7 @@ class AlbumViewSet(viewsets.ModelViewSet): |
194 | 194 | user = self.request.user |
195 | 195 | user_role = str(UserLevel.objects.get( |
196 | 196 | priority=user.get_priority()).name) |
197 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
197 | + if user_role in ("Unit-PI", "Admin"): | |
198 | 198 | sequences = Sequence.objects.all().order_by("-updated") |
199 | 199 | else: |
200 | 200 | sequences = Sequence.objects.filter( |
... | ... | @@ -219,7 +219,7 @@ class PlanViewSet(viewsets.ModelViewSet): |
219 | 219 | user = self.request.user |
220 | 220 | user_role = str(UserLevel.objects.get( |
221 | 221 | priority=user.get_priority()).name) |
222 | - if user_role in ("Unit-PI", "Unit-board", "Admin"): | |
222 | + if user_role in ("Unit-PI", "Admin"): | |
223 | 223 | sequences = Sequence.objects.all().order_by("-updated") |
224 | 224 | else: |
225 | 225 | sequences = Sequence.objects.filter( | ... | ... |
src/core/pyros_django/dashboard/templatetags/tags.py
... | ... | @@ -81,7 +81,7 @@ def can_view_settings(request): |
81 | 81 | else: |
82 | 82 | request.session["role"] = UserLevel.objects.get(name="Visitor").name |
83 | 83 | |
84 | - return request.user.is_authenticated and request.session["role"] in ("Admin","Operator","Unit-PI","Unit-Board","Observer") | |
84 | + return request.user.is_authenticated and request.session["role"] in ("Admin","Operator","Unit-PI","Unit-board","Observer") | |
85 | 85 | |
86 | 86 | @register.filter |
87 | 87 | def is_past_due(value): | ... | ... |
src/core/pyros_django/misc/fixtures/initial_fixture_TZ.json
... | ... | @@ -374,7 +374,7 @@ |
374 | 374 | "model": "common.userlevel", |
375 | 375 | "pk": 7, |
376 | 376 | "fields": { |
377 | - "name": "Unit board", | |
377 | + "name": "Unit-board", | |
378 | 378 | "desc": "", |
379 | 379 | "priority": 6, |
380 | 380 | "quota": 9999.0 |
... | ... | @@ -1070,10 +1070,10 @@ |
1070 | 1070 | "is_superuser": true, |
1071 | 1071 | "first_name": "Unit", |
1072 | 1072 | "last_name": "Board", |
1073 | - "email": "Unit-Board@example.com", | |
1073 | + "email": "Unit-board@example.com", | |
1074 | 1074 | "is_staff": true, |
1075 | 1075 | "date_joined": "2021-05-20T09:03:37.108Z", |
1076 | - "username": "Unit-Board@example.com", | |
1076 | + "username": "Unit-board@example.com", | |
1077 | 1077 | "is_active": true, |
1078 | 1078 | "first_time": false, |
1079 | 1079 | "country": 1, | ... | ... |
src/core/pyros_django/misc/fixtures/tests/common_test_TZ.json
src/core/pyros_django/misc/fixtures/tests/scientific_program_TZ.json
src/core/pyros_django/misc/fixtures/tests/sequences_test_TZ.json
src/core/pyros_django/monitoring/urls.py
... | ... | @@ -7,4 +7,5 @@ urlpatterns = [ |
7 | 7 | path('weather/config', views.weather_config, name="weather_config"), |
8 | 8 | path('weather/config/update', views.weather_config_update, name="weather_config_update"), |
9 | 9 | path('weather_history', views.weather_history, name="weather_history"), |
10 | + path('weather_history_export>', views.export_weather_data, name="weather_history_export"), | |
10 | 11 | ] | ... | ... |
src/core/pyros_django/obsconfig/views.py
... | ... | @@ -119,7 +119,7 @@ def computer_details(request, computer_name): |
119 | 119 | |
120 | 120 | |
121 | 121 | @login_required |
122 | -@level_required("Admin", "Unit-PI", "Unit-board", "Operator", "Observer") | |
122 | +@level_required("Admin", "Unit-PI", "Operator", "Observer") | |
123 | 123 | def device_details(request, device_name): |
124 | 124 | config = OBSConfig( |
125 | 125 | os.environ["PATH_TO_OBSCONF_FILE"], os.environ["unit_name"]) |
... | ... | @@ -337,7 +337,7 @@ def save_config(request): |
337 | 337 | |
338 | 338 | |
339 | 339 | @ login_required |
340 | -@ level_required("Admin", "Unit-PI", "Unit-board", "Operator", "Observer") | |
340 | +@ level_required("Admin", "Unit-PI", "Operator", "Observer") | |
341 | 341 | @ csrf_exempt |
342 | 342 | def view_raw_component_config_file(request): |
343 | 343 | COMPONENT_PATH = os.path.join( |
... | ... | @@ -353,7 +353,7 @@ def view_raw_component_config_file(request): |
353 | 353 | |
354 | 354 | |
355 | 355 | @ login_required |
356 | -@ level_required("Admin", "Unit-PI", "Unit-board", "Operator", "Observer") | |
356 | +@ level_required("Admin", "Unit-PI", "Operator", "Observer") | |
357 | 357 | @ csrf_exempt |
358 | 358 | def view_raw_generic_device_config_file(request): |
359 | 359 | GENERIC_DEVICES_PATH = os.path.join( |
... | ... | @@ -365,7 +365,7 @@ def view_raw_generic_device_config_file(request): |
365 | 365 | |
366 | 366 | |
367 | 367 | @ login_required |
368 | -@ level_required("Admin", "Unit-PI", "Unit-board", "Operator", "Observer") | |
368 | +@ level_required("Admin", "Unit-PI", "Operator", "Observer") | |
369 | 369 | @ csrf_exempt |
370 | 370 | def view_raw_device_config_file(request): |
371 | 371 | obs_folder = os.environ["PATH_TO_OBSCONF_FOLDER"] |
... | ... | @@ -376,6 +376,6 @@ def view_raw_device_config_file(request): |
376 | 376 | |
377 | 377 | |
378 | 378 | @ login_required |
379 | -@ level_required("Admin", "Unit-PI", "Unit-board", "Operator", "Observer") | |
379 | +@ level_required("Admin", "Unit-PI", "Operator", "Observer") | |
380 | 380 | def obs_config_help(request): |
381 | 381 | return render(request, "obsconfig/obs_config_help.html") | ... | ... |
src/core/pyros_django/pyros/settings.py
... | ... | @@ -439,7 +439,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' |
439 | 439 | |
440 | 440 | python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '.' -f 1,2",shell=True,stdout=subprocess.PIPE,universal_newlines=True) |
441 | 441 | python_version = python_version.stdout |
442 | -day = "2022-05-04" | |
442 | +day = "2022-05-05" | |
443 | 443 | django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1] |
444 | 444 | pyros_version = read_version_number_from_file(f"{BASE_DIR}/../../../VERSION") |
445 | 445 | ... | ... |
src/core/pyros_django/routine_manager/views.py
... | ... | @@ -1025,6 +1025,7 @@ def copy_sequence(request, seq_id): |
1025 | 1025 | new_seq.name = name |
1026 | 1026 | new_seq.pk = None |
1027 | 1027 | new_seq._state.adding = True |
1028 | + new_seq.pyros_user = request.user | |
1028 | 1029 | new_seq.complete = False |
1029 | 1030 | new_seq.status = Sequence.DRAFT |
1030 | 1031 | new_seq.save() | ... | ... |
src/core/pyros_django/scientific_program/views.py
... | ... | @@ -799,7 +799,7 @@ def institute_list(request): |
799 | 799 | # Exploitation Periods CRUD |
800 | 800 | |
801 | 801 | @login_required |
802 | -@level_required("Admin", "Unit-PI", "Unit board") | |
802 | +@level_required("Admin", "Unit-PI", "Unit-board") | |
803 | 803 | def create_period(request): |
804 | 804 | form = PeriodForm() |
805 | 805 | today = timezone.now().date() |
... | ... | @@ -1025,7 +1025,7 @@ def edit_period(request, id): |
1025 | 1025 | |
1026 | 1026 | |
1027 | 1027 | @login_required |
1028 | -@level_required("Admin", "Unit-PI", "Unit-board", "Observer") | |
1028 | +@level_required("Admin", "Unit-PI", "Observer") | |
1029 | 1029 | def detail_period(request, id): |
1030 | 1030 | period = get_object_or_404(Period, pk=id) |
1031 | 1031 | sp_periods = SP_Period.objects.filter(period=period) |
... | ... | @@ -1102,10 +1102,10 @@ def add_science_theme(request): |
1102 | 1102 | |
1103 | 1103 | |
1104 | 1104 | @login_required |
1105 | -@level_required("Admin","Unit-PI","Unit-board","TAC") | |
1105 | +@level_required("Admin","Unit-PI","TAC") | |
1106 | 1106 | def science_theme_list(request): |
1107 | 1107 | science_themes = ScienceTheme.objects.all() |
1108 | - CAN_ADD_SCIENCE_THEME = request.session.get("role") in ("Admin","Unit-PI","Unit-board","TAC") | |
1108 | + CAN_ADD_SCIENCE_THEME = request.session.get("role") in ("Admin","Unit-PI","TAC") | |
1109 | 1109 | return render(request,"scientific_program/science_theme_list.html",{ |
1110 | 1110 | "science_themes":science_themes, |
1111 | 1111 | "CAN_ADD_SCIENCE_THEME": CAN_ADD_SCIENCE_THEME |
... | ... | @@ -1117,7 +1117,7 @@ def detail_science_theme(request,id): |
1117 | 1117 | science_theme = get_object_or_404(ScienceTheme,pk=id) |
1118 | 1118 | all_scientific_programs = ScientificProgram.objects.filter(science_theme=science_theme) |
1119 | 1119 | sp_of_user = None |
1120 | - CAN_VIEW_ALL_SP = request.session.get("role") in ("Admin","Unit-PI","Unit-board","TAC") | |
1120 | + CAN_VIEW_ALL_SP = request.session.get("role") in ("Admin","Unit-PI","TAC") | |
1121 | 1121 | CAN_EDIT_SCIENCE_THEME = request.session.get("role") in ("Admin","Unit-PI","Unit-board") |
1122 | 1122 | percentage_of_user_of_that_theme = (PyrosUser.objects.filter(referee_themes__in=[science_theme]).count() / PyrosUser.objects.all().count()) * 100 |
1123 | 1123 | if not CAN_VIEW_ALL_SP: | ... | ... |
src/core/pyros_django/user_manager/templates/user_manager/roles_description.html
src/core/pyros_django/user_manager/templates/user_manager/user_detail_edit.html
... | ... | @@ -47,8 +47,8 @@ |
47 | 47 | {% comment %} |
48 | 48 | input name is the same for all role so we can retrieve a list of selected values |
49 | 49 | {% endcomment %} |
50 | - {# if user is sp_pi, he can have the "unit board" role #} | |
51 | - {% if role.name == "Unit board" and is_sp_pi %} | |
50 | + {# if user is sp_pi, he can have the "Unit-board" role #} | |
51 | + {% if role.name == "Unit-board" and is_sp_pi %} | |
52 | 52 | |
53 | 53 | {% if role.name in user_edit.get_roles_str %} |
54 | 54 | <input type="checkbox" checked id="{{role.name}}" name="roles" value="{{role.id}}"> | ... | ... |
src/core/pyros_django/user_manager/views.py
... | ... | @@ -206,7 +206,7 @@ def delete_user(request, pk): |
206 | 206 | |
207 | 207 | |
208 | 208 | @login_required |
209 | -@level_required("Admin", "Observer", "Management", "Operator", "Unit-PI", "TAC", "Unit board") | |
209 | +@level_required("Admin", "Observer", "Management", "Operator", "Unit-PI", "TAC", "Unit-board") | |
210 | 210 | def users(request): |
211 | 211 | current_user = request.user |
212 | 212 | pyros_users_with_roles = [] |
... | ... | @@ -217,7 +217,7 @@ def users(request): |
217 | 217 | role = request.session.get("role") |
218 | 218 | else: |
219 | 219 | role = current_user.get_priority() |
220 | - if role in "Admin,Unit-PI,Unit board": | |
220 | + if role in "Admin,Unit-PI,Unit-board": | |
221 | 221 | pyros_users_with_roles = PyrosUser.objects.exclude( |
222 | 222 | is_active=False).order_by("-id") |
223 | 223 | inactive_pyros_users = PyrosUser.objects.filter( |
... | ... | @@ -235,7 +235,7 @@ def users(request): |
235 | 235 | admin_and_unit_users = PyrosUser.objects.filter( |
236 | 236 | user_level__name__in=("Unit-PI", "Unit-board", "Admin")).distinct() |
237 | 237 | nb_of_scientific_program = ScientificProgram.objects.count() |
238 | - CAN_ADD_USER = request.session.get("role") in ("Admin,Unit-PI,Unit board") | |
238 | + CAN_ADD_USER = request.session.get("role") in ("Admin,Unit-PI,Unit-board") | |
239 | 239 | # need the negative to calculate in the template for adjusting correctly the information display |
240 | 240 | negative_nb_scientific_program = -nb_of_scientific_program |
241 | 241 | |
... | ... | @@ -261,14 +261,14 @@ def users(request): |
261 | 261 | |
262 | 262 | |
263 | 263 | @login_required |
264 | -@level_required("Admin", "Unit-PI", "Unit board") | |
264 | +@level_required("Admin", "Unit-PI", "Unit-board") | |
265 | 265 | def change_activate(request, pk, current_user_id): |
266 | 266 | role = None |
267 | 267 | if request.session.get("role") != None: |
268 | 268 | role = request.session.get("role") |
269 | 269 | else: |
270 | 270 | role = UserLevel.objects.get(priority=request.user.get_priority()).name |
271 | - if role in ["Admin", "Unit-PI", "Unit board"]: | |
271 | + if role in ["Admin", "Unit-PI", "Unit-board"]: | |
272 | 272 | try: |
273 | 273 | user = get_object_or_404(PyrosUser, pk=pk) |
274 | 274 | user.is_active = not user.is_active |
... | ... | @@ -301,7 +301,7 @@ def change_activate(request, pk, current_user_id): |
301 | 301 | |
302 | 302 | |
303 | 303 | @login_required |
304 | -# @level_required("Admin","Observer","Management","Operator","Unit-PI","TAC","Unit board") | |
304 | +# @level_required("Admin","Observer","Management","Operator","Unit-PI","TAC","Unit-board") | |
305 | 305 | def user_detail_view(request, pk): |
306 | 306 | try: |
307 | 307 | is_last_user = PyrosUser.objects.count() == 1 |
... | ... | @@ -343,8 +343,8 @@ def user_detail_edit(request, pk): |
343 | 343 | role = request.session.get("role") |
344 | 344 | else: |
345 | 345 | role = request.user.get_priority() |
346 | - # If its not his user profile or user isn't Unit-PI, Unit board, Admin or SP-PI, He can't edit this user profile and he is redirected to home page | |
347 | - if (request.user.id != pk and role not in ("Admin", "Unit-PI", "Unit board")): | |
346 | + # If its not his user profile or user isn't Unit-PI, Unit-board, Admin or SP-PI, He can't edit this user profile and he is redirected to home page | |
347 | + if (request.user.id != pk and role not in ("Admin", "Unit-PI", "Unit-board")): | |
348 | 348 | return HttpResponseRedirect(reverse('index')) |
349 | 349 | edit = get_object_or_404(PyrosUser, pk=pk) |
350 | 350 | is_sp_pi = ScientificProgram.objects.filter(sp_pi=edit).count() > 0 | ... | ... |