Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
code-geek committed Aug 16, 2024
1 parent b003aa6 commit 5156c44
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions sde_collections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from .forms import CollectionGithubIssueForm, CommentsForm, RequiredUrlForm
from .models.candidate_url import CandidateURL, ResolvedTitle, ResolvedTitleError
from .models.collection import Collection, Comments, RequiredUrls,WorkflowHistory
from .models.collection import Collection, Comments, RequiredUrls, WorkflowHistory
from .models.collection_choice_fields import (
ConnectorChoices,
CurationStatusChoices,
Expand Down Expand Up @@ -140,13 +140,17 @@ def get_context_data(self, **kwargs):
)
if "comments_form" not in context:
context["comments_form"] = CommentsForm()

# Initialize a dictionary to hold the most recent history for each workflow status
timeline_history = {}

# Get the most recent history for each workflow status
recent_histories = WorkflowHistory.objects.filter(collection=self.get_object()).order_by('workflow_status', '-created_at').distinct('workflow_status')

recent_histories = (
WorkflowHistory.objects.filter(collection=self.get_object())
.order_by("workflow_status", "-created_at")
.distinct("workflow_status")
)

# Populate the dictionary with the actual history objects
for history in recent_histories:
timeline_history[history.workflow_status] = history
Expand All @@ -155,20 +159,23 @@ def get_context_data(self, **kwargs):
for status in WorkflowStatusChoices:
if status not in timeline_history:
timeline_history[status] = {
'workflow_status': status,
'created_at': None,
'label': WorkflowStatusChoices(status).label,
"workflow_status": status,
"created_at": None,
"label": WorkflowStatusChoices(status).label,
}
context['timeline_history'] = [timeline_history[status] for status in WorkflowStatusChoices]

context["timeline_history"] = [timeline_history[status] for status in WorkflowStatusChoices]
context["required_urls"] = RequiredUrls.objects.filter(collection=self.get_object())
context["segment"] = "collection-detail"
context["comments"] = Comments.objects.filter(collection=self.get_object()).order_by("-created_at")
context["workflow_history"] = WorkflowHistory.objects.filter(collection=self.get_object()).order_by('-created_at')
context["workflow_history"] = WorkflowHistory.objects.filter(collection=self.get_object()).order_by(
"-created_at"
)
context["workflow_status_choices"] = WorkflowStatusChoices

return context


class RequiredUrlsDeleteView(LoginRequiredMixin, DeleteView):
model = RequiredUrls

Expand Down Expand Up @@ -216,25 +223,22 @@ def get_context_data(self, **kwargs):

return context

class SdeDashboardView(LoginRequiredMixin,ListView ):


class SdeDashboardView(LoginRequiredMixin, ListView):

model = Collection
template_name = "sde_collections/sde_dashboard.html"
context_object_name = "collections"

def get_queryset(self):
return (
super()
.get_queryset()
)
return super().get_queryset()

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["segment"] = "collections"
return context



class CollectionFilterMixin:
def get_queryset(self):
if not self.request.method == "GET":
Expand Down Expand Up @@ -387,12 +391,13 @@ class CollectionViewSet(viewsets.ModelViewSet):
queryset = Collection.objects.all()
serializer_class = CollectionSerializer


class CollectionReadViewSet(viewsets.ReadOnlyModelViewSet):
queryset = Collection.objects.all()
serializer_class = CollectionReadSerializer


class PushToGithubView(APIView):
class PushToGithubView(APIView):
def post(self, request):
collection_ids = request.POST.getlist("collection_ids[]", [])
if len(collection_ids) == 0:
Expand Down

0 comments on commit 5156c44

Please sign in to comment.