19
19
20
20
from .forms import CollectionGithubIssueForm , CommentsForm , RequiredUrlForm
21
21
from .models .candidate_url import CandidateURL , ResolvedTitle , ResolvedTitleError
22
- from .models .collection import Collection , Comments , RequiredUrls ,WorkflowHistory
22
+ from .models .collection import Collection , Comments , RequiredUrls , WorkflowHistory
23
23
from .models .collection_choice_fields import (
24
24
ConnectorChoices ,
25
25
CurationStatusChoices ,
@@ -140,13 +140,17 @@ def get_context_data(self, **kwargs):
140
140
)
141
141
if "comments_form" not in context :
142
142
context ["comments_form" ] = CommentsForm ()
143
-
143
+
144
144
# Initialize a dictionary to hold the most recent history for each workflow status
145
145
timeline_history = {}
146
-
146
+
147
147
# Get the most recent history for each workflow status
148
- recent_histories = WorkflowHistory .objects .filter (collection = self .get_object ()).order_by ('workflow_status' , '-created_at' ).distinct ('workflow_status' )
149
-
148
+ recent_histories = (
149
+ WorkflowHistory .objects .filter (collection = self .get_object ())
150
+ .order_by ("workflow_status" , "-created_at" )
151
+ .distinct ("workflow_status" )
152
+ )
153
+
150
154
# Populate the dictionary with the actual history objects
151
155
for history in recent_histories :
152
156
timeline_history [history .workflow_status ] = history
@@ -155,20 +159,23 @@ def get_context_data(self, **kwargs):
155
159
for status in WorkflowStatusChoices :
156
160
if status not in timeline_history :
157
161
timeline_history [status ] = {
158
- ' workflow_status' : status ,
159
- ' created_at' : None ,
160
- ' label' : WorkflowStatusChoices (status ).label ,
162
+ " workflow_status" : status ,
163
+ " created_at" : None ,
164
+ " label" : WorkflowStatusChoices (status ).label ,
161
165
}
162
-
163
- context [' timeline_history' ] = [timeline_history [status ] for status in WorkflowStatusChoices ]
166
+
167
+ context [" timeline_history" ] = [timeline_history [status ] for status in WorkflowStatusChoices ]
164
168
context ["required_urls" ] = RequiredUrls .objects .filter (collection = self .get_object ())
165
169
context ["segment" ] = "collection-detail"
166
170
context ["comments" ] = Comments .objects .filter (collection = self .get_object ()).order_by ("-created_at" )
167
- context ["workflow_history" ] = WorkflowHistory .objects .filter (collection = self .get_object ()).order_by ('-created_at' )
171
+ context ["workflow_history" ] = WorkflowHistory .objects .filter (collection = self .get_object ()).order_by (
172
+ "-created_at"
173
+ )
168
174
context ["workflow_status_choices" ] = WorkflowStatusChoices
169
175
170
176
return context
171
177
178
+
172
179
class RequiredUrlsDeleteView (LoginRequiredMixin , DeleteView ):
173
180
model = RequiredUrls
174
181
@@ -216,25 +223,22 @@ def get_context_data(self, **kwargs):
216
223
217
224
return context
218
225
219
- class SdeDashboardView (LoginRequiredMixin ,ListView ):
220
-
226
+
227
+ class SdeDashboardView (LoginRequiredMixin , ListView ):
228
+
221
229
model = Collection
222
230
template_name = "sde_collections/sde_dashboard.html"
223
231
context_object_name = "collections"
224
232
225
233
def get_queryset (self ):
226
- return (
227
- super ()
228
- .get_queryset ()
229
- )
234
+ return super ().get_queryset ()
230
235
231
236
def get_context_data (self , ** kwargs ):
232
237
context = super ().get_context_data (** kwargs )
233
238
context ["segment" ] = "collections"
234
239
return context
235
240
236
241
237
-
238
242
class CollectionFilterMixin :
239
243
def get_queryset (self ):
240
244
if not self .request .method == "GET" :
@@ -387,12 +391,13 @@ class CollectionViewSet(viewsets.ModelViewSet):
387
391
queryset = Collection .objects .all ()
388
392
serializer_class = CollectionSerializer
389
393
394
+
390
395
class CollectionReadViewSet (viewsets .ReadOnlyModelViewSet ):
391
396
queryset = Collection .objects .all ()
392
397
serializer_class = CollectionReadSerializer
393
398
394
399
395
- class PushToGithubView (APIView ):
400
+ class PushToGithubView (APIView ):
396
401
def post (self , request ):
397
402
collection_ids = request .POST .getlist ("collection_ids[]" , [])
398
403
if len (collection_ids ) == 0 :
0 commit comments