Skip to content

Commit

Permalink
Add counts to superuser page. Closes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
elserj committed Jan 26, 2024
1 parent 56f1c23 commit 4478ec9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion annotations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class AnnotationAddView(FormView):
form_class = AnnotationAddForm
model = Annotation
template_name = 'annotations/annotation_add.html'
success_url = reverse_lazy('annotations:import_success')
success_url = reverse_lazy('annotations:request_success')

def get(self, request):
return self.render_to_response(self.get_context_data())
Expand Down
6 changes: 4 additions & 2 deletions curate/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import include, path, reverse_lazy
from django.views.generic import RedirectView, TemplateView
from .views import HomeView
from .views import HomeView, SuperUserView


urlpatterns = [
path('admin/', admin.site.urls),
Expand All @@ -31,9 +32,10 @@
path('about', TemplateView.as_view(template_name='about_us.html'), name='about'),
path('contact', TemplateView.as_view(template_name='contact.html'), name='contact'),
path('import', TemplateView.as_view(template_name='import_base.html'), name='import'),
path('superuser', TemplateView.as_view(template_name='superuser.html'), name='superuser'),
path('superuser', SuperUserView.as_view(template_name='superuser.html'), name='superuser'),
path('moderator', TemplateView.as_view(template_name='moderator.html'), name='moderator'),
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('images/favicon.ico'))),
path('oidc/', include('mozilla_django_oidc.urls')),
path('', HomeView.as_view(template_name='home.html')),
]

22 changes: 21 additions & 1 deletion curate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

# models import
from taxon.models import Taxon
from annotations.models import Annotation
from annotations.models import Annotation, AnnotationApproval
from accounts.models import User
from genes.models import GeneApproval

# choices import
from curate.choices import ApprovalStates


class HomeView(TemplateView):
Expand Down Expand Up @@ -54,3 +59,18 @@ def get_context_data(self, **kwargs):
annotation_10_list = Annotation.objects.filter(pk__in=list(annot_dict.values())).order_by('-id')
context['latest_annotations'] = annotation_10_list
return context


class SuperUserView(TemplateView):
template_name = 'superuser.html'

def get(self, request, *args, **kwargs):
return self.render_to_response(self.get_context_data())

def get_context_data(self, **kwargs):
context = super(SuperUserView, self).get_context_data(**kwargs)
context['user_approval_count'] = User.objects.filter(is_approved=False).count()
context['gene_approval_count'] = GeneApproval.objects.filter(status=ApprovalStates.PENDING).count()
context['annotation_approval_count'] = AnnotationApproval.objects.filter(status=ApprovalStates.PENDING).count()

return context
6 changes: 3 additions & 3 deletions templates/superuser.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ <h2 align="center">All important pages for a superuser</h2>
<h3 class="card-title" align="center">Approvals</h3>
<div class="card-body">
<h4 class="card-title"><a href="{% url 'accounts:approve' %}">Account approval page</a></h4>
<p class="card-text">Approve user accounts</p>
<p class="card-text">Approve user accounts awaiting approval ({{ user_approval_count }})</p>
<br>
<h4 class="card-title"><a href="{% url 'genes:approval' %}">Gene approval page</a></h4>
<p class="card-text">Approve new and changed genes</p>
<p class="card-text">Approve new and changed genes awaiting approval ({{ gene_approval_count }})</p>
<br>
<h4 class="card-title"><a href="{% url 'annotations:approval' %}">Annotation approval page</a></h4>
<p class="card-text">Approve new annotations</p>
<p class="card-text">Approve new annotations awaiting approval ({{ annotation_approval_count }})</p>
</div>
</div>
<div class="card border-primary mb-3">
Expand Down

0 comments on commit 4478ec9

Please sign in to comment.