File tree 5 files changed +31
-7
lines changed
5 files changed +31
-7
lines changed Original file line number Diff line number Diff line change 209
209
'PROJECT_IMPORTS_LIST' ,
210
210
'PROJECT_SEND_ISSUE' ,
211
211
'PROJECT_QUESTIONS_AUTOSAVE' ,
212
- 'NESTED_PROJECTS'
212
+ 'NESTED_PROJECTS' ,
213
+ 'PROJECT_VIEWS_SYNC' ,
214
+ 'PROJECT_TASKS_SYNC'
213
215
]
214
216
215
217
SETTINGS_API = [
Original file line number Diff line number Diff line change 4
4
from django .utils .translation import gettext_lazy as _
5
5
6
6
from rest_framework import serializers
7
+ from rest_framework .exceptions import ValidationError
7
8
8
9
from rdmo .questions .models import Catalog
9
10
from rdmo .services .validators import ProviderValidator
@@ -93,6 +94,18 @@ class Meta:
93
94
ProjectParentValidator ()
94
95
]
95
96
97
+ def validate_views (self , value ):
98
+ """Block updates to views if syncing is enabled."""
99
+ if settings .PROJECT_VIEWS_SYNC :
100
+ raise ValidationError (_ ('Updating views is not allowed when PROJECT_VIEWS_SYNC is enabled.' ))
101
+ return value
102
+
103
+ def validate_tasks (self , value ):
104
+ """Block updates to tasks if syncing is enabled."""
105
+ if settings .PROJECT_TASKS_SYNC :
106
+ raise ValidationError (_ ('Updating tasks is not allowed when PROJECT_TASKS_SYNC is enabled.' ))
107
+ return value
108
+
96
109
97
110
class ProjectCopySerializer (ProjectSerializer ):
98
111
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ <h2>{% trans 'Tasks' %}</h2>
21
21
< th style ="width: 15% "> {% trans 'Time frame' %}</ th >
22
22
< th style ="width: 15% "> {% trans 'Status' %}</ th >
23
23
< th style ="width: 10% " class ="text-right ">
24
- {% if can_change_project %}
24
+ {% if can_change_project and not settings.PROJECT_TASKS_SYNC %}
25
25
< a href ="{% url 'project_update_tasks' project.pk %} " title ="{% trans 'Update project tasks.' %} ">
26
26
< i class ="fa fa-pencil "> </ i >
27
27
</ a >
@@ -67,7 +67,7 @@ <h2>{% trans 'Tasks' %}</h2>
67
67
68
68
{% else %}
69
69
70
- {% if can_change_project %}
70
+ {% if can_change_project and not settings.PROJECT_TASKS_SYNC %}
71
71
< p class ="project-update ">
72
72
< a href ="{% url 'project_update_tasks' project.pk %} " title ="{% trans 'Update project tasks.' %} ">
73
73
< i class ="fa fa-pencil "> </ i >
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ <h2>{% trans 'Views' %}</h2>
19
19
< th style ="width: 20% "> {% trans 'View' %}</ th >
20
20
< th style ="width: 60% "> {% trans 'Description' %}</ th >
21
21
< th style ="width: 20% " class ="text-right ">
22
- {% if can_change_project %}
22
+ {% if can_change_project and not settings.PROJECT_VIEWS_SYNC %}
23
23
< a href ="{% url 'project_update_views' project.pk %} " title ="{% trans 'Update project views' %} ">
24
24
< i class ="fa fa-pencil "> </ i >
25
25
</ a >
@@ -45,7 +45,7 @@ <h2>{% trans 'Views' %}</h2>
45
45
46
46
{% else %}
47
47
48
- {% if can_change_project %}
48
+ {% if can_change_project and not settings.PROJECT_VIEWS_SYNC %}
49
49
< p class ="project-update ">
50
50
< a href ="{% url 'project_update_views' project.pk %} " title ="{% trans 'Update project views' %} ">
51
51
< i class ="fa fa-pencil "> </ i >
Original file line number Diff line number Diff line change @@ -64,11 +64,20 @@ def get_context_data(self, **kwargs):
64
64
context ['catalogs' ] = Catalog .objects .filter_current_site () \
65
65
.filter_group (self .request .user ) \
66
66
.filter_availability (self .request .user )
67
- context ['tasks_available' ] = Task .objects .filter_current_site () \
67
+
68
+ if settings .PROJECT_TASKS_SYNC :
69
+ # tasks should be synced, the user can not change them
70
+ context ['tasks_available' ] = project .tasks .exists ()
71
+ else :
72
+ context ['tasks_available' ] = Task .objects .filter_current_site () \
68
73
.filter_catalog (self .object .catalog ) \
69
74
.filter_group (self .request .user ) \
70
75
.filter_availability (self .request .user ).exists ()
71
- context ['views_available' ] = View .objects .filter_current_site () \
76
+ if settings .PROJECT_VIEWS_SYNC :
77
+ # views should be synced, the user can not change them
78
+ context ['views_available' ] = project .views .exists ()
79
+ else :
80
+ context ['views_available' ] = View .objects .filter_current_site () \
72
81
.filter_catalog (self .object .catalog ) \
73
82
.filter_group (self .request .user ) \
74
83
.filter_availability (self .request .user ).exists ()
You can’t perform that action at this time.
0 commit comments