Allow the user to toggle between their teams and events, and all teams and events
This commit is contained in:
parent
84d500e106
commit
2952a1eb0b
6 changed files with 40 additions and 6 deletions
|
@ -77,7 +77,6 @@ form {
|
|||
|
||||
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
{% if request.user.is_authenticated %}
|
||||
<li class="nav-item{% if request.resolver_match.url_name == "events" %} active{% endif %}">
|
||||
<a class="nav-link" href="{% url 'events' %}">Events{% if request.resolver_match.url_name == "events" %} <span class="sr-only">(current)</span>{% endif %}</a>
|
||||
</li>
|
||||
|
@ -89,7 +88,6 @@ form {
|
|||
<a class="nav-link" href="{% url 'places' %}">Places{% if request.resolver_match.url_name == "places" %} <span class="sr-only">(current)</span>{% endif %}</a>
|
||||
</li>
|
||||
{% endcomment %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
{% if request.user.is_authenticated %}
|
||||
|
|
|
@ -7,8 +7,13 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>Your upcoming events</h3>
|
||||
<div class="container">
|
||||
<div class="col-12 text-center mb-2">
|
||||
<div class="btn-group" role="group">
|
||||
<a class="btn {% if not request.user.is_authenticated %}disabled {% endif %}{% if active == 'my' %}btn-primary{% else %}btn-secondary{% endif %}" href="{% url 'events' %}">My Events</a>
|
||||
<a class="btn {% if active == 'all' %}btn-primary{% else %}btn-secondary{% endif %}" href="{% url 'all-events' %}">All Events</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{% for event in events_list %}
|
||||
<div class="col-md-4">
|
||||
|
|
|
@ -6,8 +6,15 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>Your Teams</h3>
|
||||
<div class="fluid-container">
|
||||
<div clas="row">
|
||||
<div class="col-12 text-center mb-2">
|
||||
<div class="btn-group" role="group">
|
||||
<a class="btn {% if not request.user.is_authenticated %}disabled {% endif %}{% if active == 'my' %}btn-primary{% else %}btn-secondary{% endif %}" href="{% url 'teams' %}">My Teams</a>
|
||||
<a class="btn {% if active == 'all' %}btn-primary{% else %}btn-secondary{% endif %}" href="{% url 'all-teams' %}">All Teams</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{% for team in teams %}
|
||||
<div class="col-md-4">
|
||||
|
|
|
@ -48,14 +48,16 @@ urlpatterns = [
|
|||
path('profile/<int:user_id>/', views.show_profile, name='show-profile'),
|
||||
|
||||
path('events/', views.events_list, name='events'),
|
||||
path('+create-team/', views.create_team, name='create-team'),
|
||||
path('events/all/', views.events_list_all, name='all-events'),
|
||||
path('teams/', views.teams_list, name='teams'),
|
||||
path('teams/all/', views.teams_list_all, name='all-teams'),
|
||||
path('team/<int:team_id>/', views.show_team, name='show-team'),
|
||||
path('team/<int:team_id>/+edit/', views.edit_team, name='edit-team'),
|
||||
path('team/<int:team_id>/+join/', event_views.join_team, name='join-team'),
|
||||
path('team/<int:team_id>/+leave/', event_views.leave_team, name='leave-team'),
|
||||
path('team/<int:team_id>/+delete/', views.delete_team, name='delete-team'),
|
||||
|
||||
path('+create-team/', views.create_team, name='create-team'),
|
||||
path('team/+create-event/', views.create_event_team_select, name='create-event-team-select'),
|
||||
path('team/<int:team_id>/+create-event/', views.create_event, name='create-event'),
|
||||
path('events/<int:event_id>/+edit/', views.edit_event, name='edit-event'),
|
||||
|
|
|
@ -16,8 +16,19 @@ import simplejson
|
|||
|
||||
# Create your views here.
|
||||
def events_list(request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
return redirect('all-events')
|
||||
events = Event.objects.filter(attendees=request.user.profile, end_time__gt=datetime.datetime.now()).order_by('start_time')
|
||||
context = {
|
||||
'active': 'my',
|
||||
'events_list': events,
|
||||
}
|
||||
return render(request, 'get_together/events/list_events.html', context)
|
||||
|
||||
def events_list_all(request, *args, **kwargs):
|
||||
events = Event.objects.filter(end_time__gt=datetime.datetime.now()).order_by('start_time')
|
||||
context = {
|
||||
'active': 'all',
|
||||
'events_list': events,
|
||||
}
|
||||
return render(request, 'get_together/events/list_events.html', context)
|
||||
|
|
|
@ -15,10 +15,21 @@ import datetime
|
|||
import simplejson
|
||||
|
||||
# Create your views here.
|
||||
@login_required
|
||||
def teams_list(request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
return redirect('all-teams')
|
||||
|
||||
teams = request.user.profile.memberships.all()
|
||||
context = {
|
||||
'active': 'my',
|
||||
'teams': teams,
|
||||
}
|
||||
return render(request, 'get_together/teams/list_teams.html', context)
|
||||
|
||||
def teams_list_all(request, *args, **kwargs):
|
||||
teams = Team.objects.all()
|
||||
context = {
|
||||
'active': 'all',
|
||||
'teams': teams,
|
||||
}
|
||||
return render(request, 'get_together/teams/list_teams.html', context)
|
||||
|
|
Loading…
Reference in a new issue