Skip to content

Commit

Permalink
Only admin can view organization cost (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
leduythuccs authored Nov 18, 2024
1 parent d8626d1 commit 10869e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions judge/views/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,18 +567,14 @@ def get_filter(self):
return _filter & Q(organizations=self.organization)


class MonthlyCreditUsageOrganization(TitleMixin, PublicOrganizationMixin, ListView):
model = OrganizationMonthlyUsage
class MonthlyCreditUsageOrganization(LoginRequiredMixin, TitleMixin, AdminOrganizationMixin, ListView):
template_name = 'organization/usage.html'
context_object_name = 'usages'

def get_queryset(self):
return OrganizationMonthlyUsage.objects.filter(organization=self.organization)\
.order_by('time').values('time', 'consumed_credit')

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title'] = self.organization.name
context['usages'] = OrganizationMonthlyUsage.objects.filter(organization=self.organization)\
.order_by('time').values('time', 'consumed_credit')

usages = context['usages']
days = [usage['time'].isoformat() for usage in usages] + [_('Current month')]
Expand Down
6 changes: 3 additions & 3 deletions templates/organization/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ <h3>{{ _('Controls') }} <i class="fa fa-question-circle"></i></h3>
{% endif %}
{% endif %}
<br>
<div>
<a href="{{ url('organization_monthly_usage', organization.slug) }}">{{ _('Organization cost') }}</a>
</div>
{% if can_edit %}
<div>
<a href="{{ url('organization_monthly_usage', organization.slug) }}">{{ _('Organization cost') }}</a>
</div>
{% if not organization.is_open %}
<div>
<a href="{{ url('organization_requests_pending', organization.slug) }}">
Expand Down

0 comments on commit 10869e1

Please sign in to comment.