Skip to content

Commit

Permalink
Tab reorganized
Browse files Browse the repository at this point in the history
  • Loading branch information
Casassarnau committed Jul 15, 2020
1 parent 5e797fe commit c9bb20d
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 110 deletions.
40 changes: 27 additions & 13 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,38 @@
href="{% url 'admin:index' %}">Admin</a></li>
{% endif %}
{% if request.user.email_verified and request.user.has_usable_password %}
{% if request.user.is_organizer %}
<li class="{% if 'stats' in request.build_absolute_uri %}active{% endif %}"><a
href="{% url 'app_stats' %}">Stats</a></li>
<li class="{% if 'applications' in request.build_absolute_uri %}active{% endif %}"><a
href="{% url 'app_list' %}">Applications</a></li>

{% if h_r_enabled %}
<li class="{% if 'reimbursement' in request.build_absolute_uri %}active{% endif %}">
<a href="{% url 'reimbursement_list' %}">Reimbursements</a></li>
{% if request.user.is_organizer or request.user.is_volunteer_accepted %}
<li class="{% if 'hacker' in request.build_absolute_uri %}active{% endif %}">
{% if request.user.is_organizer %}
<a href="{% url 'app_list' %}">Hacker</a>
{% else %}
<a href="{% url 'check_in_list' %}">Check-in</a>
{% endif %}
</li>
{% if request.user.is_organizer %}
{% if request.user.has_volunteer_access %}
<li class="{% if 'volunteer' in request.build_absolute_uri %}active{% endif %}"><a
href="{% url 'volunteer_list' %}">Volunteer</a></li>
{% endif %}
{% if request.user.has_mentor_access %}
<li class="{% if 'mentor' in request.build_absolute_uri %}active{% endif %}"><a
href="{% url 'mentor_list' %}">Mentor</a></li>
{% endif %}
{% if request.user.has_sponsor_access %}
<li class="{% if 'sponsor' in request.build_absolute_uri %}active{% endif %}"><a
href="{% url 'sponsor_user_list' %}">Sponsor</a></li>
{% endif %}
{% if h_r_enabled %}
<li class="{% if 'reimbursement' in request.build_absolute_uri %}active{% endif %}">
<a href="{% url 'reimbursement_list' %}">Reimbursements</a></li>
{% endif %}
{% endif %}
{% endif %}
{% if h_hw_enabled %}
{% include 'include/hardware_tab.html' %}
{% endif %}
{% if request.user.is_organizer or request.user.is_volunteer_accepted %}
<li class="{% if 'checkin' in request.build_absolute_uri %}active{% endif %}">
<a href="{% url 'check_in_list' %}">Check-in</a></li>
{% endif %}
<li class="{% if 'stats' in request.build_absolute_uri %}active{% endif %}"><a
href="{% url 'app_stats' %}">Stats</a></li>
{% endif %}
<li><a href="{% url 'account_logout' %}">Logout</a></li>

Expand Down
11 changes: 0 additions & 11 deletions checkin/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.db.models import Q

from applications.models import BaseApplication, SponsorApplication
from user.models import User


class ApplicationCheckinFilter(django_filters.FilterSet):
Expand Down Expand Up @@ -55,13 +54,3 @@ class Meta:
template = 'django_tables2/bootstrap-responsive.html'
fields = ['name', 'user.email']
empty_text = 'All users checked in! Yay!'


class RankingListTable(tables.Table):
class Meta:
model = User
attrs = {'class': 'table table-hover'}
template = 'django_tables2/bootstrap-responsive.html'
fields = ['email', 'checkin_count', ]
empty_text = 'No checked in hacker yet... Why? :\'('
order_by = '-checkin_count'
9 changes: 4 additions & 5 deletions checkin/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
from checkin import views

urlpatterns = [
url(r'^all/$', views.CheckInList.as_view(), name='check_in_list'),
url(r'^ranking/$', views.CheckinRankingView.as_view(), name='check_in_ranking'),
url(r'^hacker/all/$', views.CheckInList.as_view(), name='check_in_list'),
url(r'(?P<type>[a-z_\-]{1,10})/(?P<id>[\w-]+)$', views.CheckInHackerView.as_view(),
name='check_in_hacker'),
url(r'^volunteer/$', views.CheckinVolunteerList.as_view(), name='check_in_volunteer_list'),
url(r'^mentor/$', views.CheckinMentorList.as_view(), name='check_in_mentor_list'),
url(r'^sponsor/$', views.CheckinSponsorList.as_view(), name='check_in_sponsor_list'),
url(r'^volunteer/all/$', views.CheckinVolunteerList.as_view(), name='check_in_volunteer_list'),
url(r'^mentor/all/$', views.CheckinMentorList.as_view(), name='check_in_mentor_list'),
url(r'^sponsor/all/$', views.CheckinSponsorList.as_view(), name='check_in_sponsor_list'),
]
48 changes: 13 additions & 35 deletions checkin/views.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
from django.contrib import messages
from django.db.models import Count
from django.http import HttpResponseRedirect, Http404
from django.views.generic import TemplateView
from django_filters.views import FilterView
from django_tables2 import SingleTableMixin

from app.mixins import TabsViewMixin
from app.utils import reverse
from app.views import TabsView
from applications import models
from checkin.models import CheckIn
from checkin.tables import ApplicationsCheckInTable, ApplicationCheckinFilter, RankingListTable, \
from checkin.tables import ApplicationsCheckInTable, ApplicationCheckinFilter, \
SponsorApplicationsCheckInTable, SponsorApplicationCheckinFilter
from user.mixins import IsVolunteerMixin, IsOrganizerMixin, HaveVolunteerPermissionMixin, HaveMentorPermissionMixin, \
from user.mixins import IsVolunteerMixin, HaveVolunteerPermissionMixin, HaveMentorPermissionMixin, \
HaveSponsorPermissionMixin
from user.models import User


def user_tabs(user):
tab = [('Hackers', reverse('check_in_list'), False)]
if user.is_organizer:
if user.has_volunteer_access:
tab.append(('Volunteer', reverse('check_in_volunteer_list'), False))
if user.has_mentor_access:
tab.append(('Mentor', reverse('check_in_mentor_list'), False))
if user.has_sponsor_access:
tab.append(('Sponsor', reverse('check_in_sponsor_list'), False))
tab.append(('Ranking', reverse('check_in_ranking'), False))
return tab
from organizers.views import volunteer_tabs, mentor_tabs, hacker_tabs, sponsor_tabs


def get_application_by_type(type, uuid):
Expand All @@ -49,7 +33,7 @@ class CheckInList(IsVolunteerMixin, TabsViewMixin, SingleTableMixin, FilterView)
table_pagination = {'per_page': 50}

def get_current_tabs(self):
return user_tabs(self.request.user)
return hacker_tabs(self.request.user)

def get_queryset(self):
return models.HackerApplication.objects.filter(status=models.APP_CONFIRMED)
Expand Down Expand Up @@ -94,41 +78,35 @@ def post(self, request, *args, **kwargs):
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))


class CheckinRankingView(TabsViewMixin, IsOrganizerMixin, SingleTableMixin, TemplateView):
template_name = 'checkin/ranking.html'
table_class = RankingListTable

def get_current_tabs(self):
return user_tabs(self.request.user)

def get_queryset(self):
return User.objects.annotate(
checkin_count=Count('checkin')).exclude(checkin_count=0)


class CheckinOtherUserList(TabsViewMixin, SingleTableMixin, FilterView):
template_name = 'checkin/list.html'
table_class = ApplicationsCheckInTable
filterset_class = ApplicationCheckinFilter
table_pagination = {'per_page': 50}

def get_current_tabs(self):
return user_tabs(self.request.user)


class CheckinVolunteerList(HaveVolunteerPermissionMixin, CheckinOtherUserList):
def get_queryset(self):
return models.VolunteerApplication.objects.filter(status=models.APP_CONFIRMED)

def get_current_tabs(self):
return volunteer_tabs(self.request.user)


class CheckinMentorList(HaveMentorPermissionMixin, CheckinOtherUserList):
def get_queryset(self):
return models.MentorApplication.objects.filter(status=models.APP_CONFIRMED)

def get_current_tabs(self):
return mentor_tabs(self.request.user)


class CheckinSponsorList(HaveSponsorPermissionMixin, CheckinOtherUserList):
table_class = SponsorApplicationsCheckInTable
filterset_class = SponsorApplicationCheckinFilter

def get_queryset(self):
return models.SponsorApplication.objects.filter(status=models.APP_CONFIRMED)

def get_current_tabs(self):
return sponsor_tabs(self.request.user)
2 changes: 1 addition & 1 deletion organizers/templates/blacklist_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block head_title %}All application{% endblock %}

{% block table_footer %}
{% if user.has_blacklist_acces %}
{% if user.has_blacklist_access %}
<div class="panel-footer">
<a href="{% querystring '_export'='csv' %}" class="btn-block btn btn-info">Export
CSV</a>
Expand Down
16 changes: 8 additions & 8 deletions organizers/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
from organizers import views

urlpatterns = [
url(r'^review/$', views.ReviewApplicationView.as_view(), name='review'),
url(r'^ranking/$', views.RankingView.as_view(), name='ranking'),
url(r'^(?P<id>[\w-]+)$', views.ApplicationDetailView.as_view(), name="app_detail"),
url(r'^all/$', views.ApplicationsListView.as_view(), name="app_list"),
url(r'^all/invite/$', views.InviteListView.as_view(), name="invite_list"),
url(r'^all/invite/teams/$', views.InviteTeamListView.as_view(), name="invite_teams_list"),
url(r'^dubious/$', views.DubiousApplicationsListView.as_view(), name="dubious"),
url(r'^hacker/eview/$', views.ReviewApplicationView.as_view(), name='review'),
url(r'^hacker/ranking/$', views.RankingView.as_view(), name='ranking'),
url(r'^hacker/(?P<id>[\w-]+)$', views.ApplicationDetailView.as_view(), name="app_detail"),
url(r'^hacker/all/$', views.ApplicationsListView.as_view(), name="app_list"),
url(r'^hacker/all/invite/$', views.InviteListView.as_view(), name="invite_list"),
url(r'^hacker/all/invite/teams/$', views.InviteTeamListView.as_view(), name="invite_teams_list"),
url(r'^hacker/dubious/$', views.DubiousApplicationsListView.as_view(), name="dubious"),
url(r'^volunteer/all/$', views.VolunteerApplicationsListView.as_view(), name="volunteer_list"),
url(r'^volunteer/(?P<id>[\w-]+)$', views.ReviewVolunteerApplicationView.as_view(), name="volunteer_detail"),
url(r'^sponsor/all/$', views.SponsorApplicationsListView.as_view(), name="sponsor_list"),
url(r'^sponsor/(?P<id>[\w-]+)$', views.ReviewSponsorApplicationView.as_view(), name="sponsor_detail"),
url(r'^mentor/all/$', views.MentorApplicationsListView.as_view(), name="mentor_list"),
url(r'^mentor/(?P<id>[\w-]+)$', views.ReviewMentorApplicationView.as_view(), name="mentor_detail"),
url(r'^user/sponsor/all/$', views.SponsorUserListView.as_view(), name="sponsor_user_list"),
url(r'^blacklist/$', views.BlacklistApplicationsListView.as_view(), name="blacklist"),
url(r'^hacker/blacklist/$', views.BlacklistApplicationsListView.as_view(), name="blacklist"),
]
Loading

0 comments on commit c9bb20d

Please sign in to comment.