Skip to content

Commit

Permalink
allow students to view activity info, including when an activity is s…
Browse files Browse the repository at this point in the history
…cheduled by clicking on the name of the activity in the details
  • Loading branch information
jwoglom committed Sep 12, 2015
1 parent c2c1191 commit 51e7174
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 8 deletions.
18 changes: 11 additions & 7 deletions intranet/apps/eighth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from __future__ import unicode_literals

from django.conf.urls import include, url
from .views import routers, signup, attendance, profile
from .views import routers, signup, attendance, activities, profile
from .views.admin import (
general, activities, blocks, groups, rooms, sponsors, scheduling)
general, blocks, groups, rooms, sponsors, scheduling)
from .views.admin import attendance as admin_attendance
from .views.admin import activities as admin_activities

urlpatterns = [
url(r"^$", routers.eighth_redirect_view, name="eighth_redirect"),
Expand All @@ -29,19 +30,22 @@
url(r"^/profile(?:/(?P<user_id>\d+))/signup/(?P<block_id>\d+)?$", profile.profile_signup_view, name="eighth_profile_signup"),
url(r"^/profile/edit(?:/(?P<user_id>\d+))?$", profile.edit_profile_view, name="eighth_edit_profile"),

# Roster (for students)
# Roster (for students/teachers)
url(r"^/roster/(?P<scheduled_activity_id>\d+)$", attendance.roster_view, name="eighth_roster"),
url(r"^/roster/raw/(?P<scheduled_activity_id>\d+)$", attendance.raw_roster_view, name="eighth_raw_roster"),

# Activity Info (for students/teachers)
url(r"^/activity/(?P<activity_id>\d+)$", activities.activity_view, name="eighth_activity"),

# Admin
url(r"^/admin$", general.eighth_admin_dashboard_view, name="eighth_admin_dashboard"),
]

eighth_admin_patterns = [
# Activities
url(r"^activities/add$", activities.add_activity_view, name="eighth_admin_add_activity"),
url(r"^activities/edit/(?P<activity_id>\d+)$", activities.edit_activity_view, name="eighth_admin_edit_activity"),
url(r"^activities/delete/(?P<activity_id>\d+)$", activities.delete_activity_view, name="eighth_admin_delete_activity"),
# admin_activities
url(r"^activities/add$", admin_activities.add_activity_view, name="eighth_admin_add_activity"),
url(r"^activities/edit/(?P<activity_id>\d+)$", admin_activities.edit_activity_view, name="eighth_admin_edit_activity"),
url(r"^activities/delete/(?P<activity_id>\d+)$", admin_activities.delete_activity_view, name="eighth_admin_delete_activity"),

# Blocks
url(r"^blocks/add$", blocks.add_block_view, name="eighth_admin_add_block"),
Expand Down
37 changes: 37 additions & 0 deletions intranet/apps/eighth/views/activities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import logging
from django import http
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect, get_object_or_404
from ....utils.serialization import safe_json
from ...users.models import User
from ..exceptions import SignupException
from ..models import (
EighthBlock, EighthSignup, EighthScheduledActivity, EighthActivity
)
from ..serializers import EighthBlockDetailSerializer


logger = logging.getLogger(__name__)

@login_required
def activity_view(request, activity_id=None):
activity = get_object_or_404(EighthActivity, id=activity_id)

first_block = EighthBlock.objects.get_first_upcoming_block()

scheduled_activities = EighthScheduledActivity.objects.filter(
activity=activity
)

if first_block:
scheduled_activities = scheduled_activities.filter(block__date__gte=first_block.date)

context = {
"activity": activity,
"scheduled_activities": scheduled_activities
}

return render(request, "eighth/activity.html", context)
5 changes: 5 additions & 0 deletions intranet/static/css/eighth.signup.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ h3 {
font-size: 20px;
}

h3 > a {
color: rgb(72,72,72);

}

#activity-picker h3.empty-state {
color: rgb(170, 170, 170);
text-align: center;
Expand Down
124 changes: 124 additions & 0 deletions intranet/templates/eighth/activity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{% extends "page_with_nav.html" %}
{% load phone_numbers %}
{% load staticfiles %}

{% block title %}{{ block.super }} - Activity: {{ activity }}{% endblock %}


{% block css %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static 'css/eighth.common.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/eighth.admin.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/profile.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/eighth.profile.css' %}" />
<style type="text/css">
dl dt, dl dd {
font-size: 15px;
}

dl dt {
float: left;
padding-right: 5px;
}
</style>
{% endblock %}

{% block js %}
{{ block.super }}
{% endblock %}

{% block main %}
<div class="primary-content">

{% if request.user.is_eighth_admin %}
<div class="eighth-header" style="width: 200px">
{% include "eighth/admin/start_date.html" %}
</div>
{% endif %}


<a href="{% url 'eighth_signup' %}" class="button">
<i class="fa fa-arrow-left"></i> Sign Up
</a>

<h2>Activity: {{ activity }}</h2>
<dl>
{% if activity.description %}
<dt>Description:</dt>
<dd style="width: 400px">{{ scheduled_activity.activity.description }}</dd>
{% endif %}
<dd>{{ activity.description }}</dd>
<dt>Default Sponsors:</dt>
<dd>{% for sponsor in activity.sponsors.all %}
{{ sponsor.name }}{% if not forloop.last %}, {% endif %}
{% empty %}
None
{% endfor %}</dd>

<dt>Default Rooms:</dt>
<dd>{% for sponsor in activity.rooms.all %}
{{ room }}{% if not forloop.last %}, {% endif %}
{% empty %}
None
{% endfor %}</dd>

</dl>

<section class="user-info-eighth sponsor">
<h3>Scheduled on:</h3>
<table class="fancy-table">
<thead>
<tr>
<th>Block</th>
<th>Name</th>
<th>Sponsors</th>
<th>Rooms</th>
<th></th>
</tr>
</thead>
<tbody>
{% for sch in scheduled_activities %}
<tr>
<th>
<a href="{% url 'eighth_signup' sch.block.id %}">
{{ sch.block }}
</a>
</th>
<td>
{{ sch.full_title }}
</td>
<td>
{% for sponsor in sch.get_true_sponsors %}
{{ sponsor.name }}{% if not forloop.last %}, {% endif %}
{% empty %}
None
{% endfor %}
</td>

<td>
{% for room in sch.get_true_rooms %}
{{ room }}{% if not forloop.last %}, {% endif %}
{% empty %}
None
{% endfor %}
</td>
<td>
<a class="button" href="{% url 'eighth_signup' sch.block.id %}?activity={{ sch.activity.id }}">
Sign Up
</a>
</td>
</tr>
{% empty %}
<tr>
<td>
This activity is not scheduled over the next two months.
</td>
</tr>
{% endfor %}
</tbody>
</table>
</section>


</div>
{% endblock %}
4 changes: 3 additions & 1 deletion intranet/templates/eighth/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@
<script type="text/template" id="activity-details-template">
{% verbatim %}
<h3>
<%= name %><% if (title) { %> - <%= title %><% } %>
<a href="/eighth/activity/<%= id %>" class="activity-detail-link">
<%= name %><% if (title) { %> - <%= title %><% } %>
</a>
</h3>

<% if (cancelled) { %>
Expand Down

0 comments on commit 51e7174

Please sign in to comment.