Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update schedule filters #160

Merged
merged 2 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pybay/templates/frontend/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ <h1><strong>Schedule</strong></h1>
<div class="sch-filters substicky">
<ul class="sch-filter-list">
<li data-filter="">All Talks</li>
{% for filter, name in filters %}
<li data-filter="{{ filter }}">{{ name }}</li>
{% for name, filter in filters %}
<li data-filter="{{ filter|join:" " }}">{{ name }}</li>
{% endfor %}
</ul>
</div>
Expand Down Expand Up @@ -74,20 +74,20 @@ <h4><a href="{% url 'pybay_speakers_detail' talk.speaker.name_slug %}">{{ talk.t
<script src="{% static 'new/js/schedule-filters.js' %}" async></script>

<style type="text/css">
{% for slug, _ in filters %}
.sch-schedule-filter-{{ slug }} .sch-filter-list > li[data-filter="{{ slug }}"]{% if not forloop.last %},{% endif %}{% endfor %} {
{% for _, slugs in filters %}{% for slug in slugs %}
.sch-schedule-filter-{{ slug }} .sch-filter-list > li[data-filter~="{{ slug }}"]{% if not forloop.last %},{% endif %}{% endfor %}{% if not forloop.last %},{% endif %}{% endfor %}{
background: #428bca;
color: white;
}

{% for slug, _ in filters %}
.sch-schedule-filter-{{ slug }} .sch-timeslot-kind-talk:not(.sch-talk-{{ slug }}){% if not forloop.last %},{% endif %} {% endfor %}{
{% for _, slugs in filters %}{% for slug in slugs %}
.sch-schedule-filter-{{ slug }} .sch-timeslot-kind-talk:not(.sch-talk-{{ slug }}){% if not forloop.last %},{% endif %}{% endfor %}{% if not forloop.last %},{% endif %}{% endfor %}{
opacity: .3;
}

@media(max-width: 450px) {
{% for slug, _ in filters %}
.sch-schedule-filter-{{ slug }} .sch-timeslot-kind-talk:not(.sch-talk-{{ slug }}){% if not forloop.last %},{% endif %} {% endfor %} {
{% for _, slugs in filters %}{% for slug in slugs %}
.sch-schedule-filter-{{ slug }} .sch-timeslot-kind-talk:not(.sch-talk-{{ slug }}){% if not forloop.last %},{% endif %}{% endfor %}{% if not forloop.last %},{% endif %}{% endfor %}{
display: none;
}
}
Expand Down
23 changes: 14 additions & 9 deletions pybay/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,20 @@ def _day_slots(day):


FILTER_CATEGORIES = [
"All things Web",
"DevOps",
("Fundamentals", ['fundamentals']),
("Data", ['dealingwithdata']),
("Python at Scale", ['performantpython', 'scalablepython', 'devops']),
]

ALLOWED_CATEGORIES = [
slug
for _, slugs in FILTER_CATEGORIES
for slug in slugs
]

FILTER_CATEGORIES.append(('Misc', ['other']))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why aren't these added above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that they are skipped in the 'ALLOWED_CATEGORIES', which is used to figure out which things go into 'other' and 'level-1'

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right! thanks

FILTER_CATEGORIES.append(('Beginner-friendly', ['level-1']))


def pybay_schedule(request):
if request.user.is_staff:
Expand All @@ -197,15 +207,10 @@ def pybay_schedule(request):
for schedule in schedules
]

filters = [
(name.lower().replace(' ', ''), name)
for name in FILTER_CATEGORIES
]

ctx = {
'schedules': schedules,
'filters' : filters + [('other', 'Other'), ('level-1', 'Beginner-friendly')],
'allowed_categories': [slug for slug, _ in filters]
'filters' : FILTER_CATEGORIES,
'allowed_categories': ALLOWED_CATEGORIES,
}

return render(request, "frontend/schedule.html", ctx)
1 change: 1 addition & 0 deletions static/new/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ p.question {
padding-top: 4px;
padding-bottom: 4px;
text-align: left;
transition: opacity 0.2s ease-out;
}

.sch-timeslot-kind-talk > * {
Expand Down
9 changes: 7 additions & 2 deletions static/new/js/schedule-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
var filter = target.closest('li').data('filter');
if (filter === undefined) return;
var schedule = target.closest('.' + parentClass);
var alreadySelected = filter === '' || schedule.hasClass(prefix + filter);
schedule.data('filter');
var alreadySelected = filter === '' || schedule.data('filter') === filter;
schedule.data('filter', filter);
schedule.removeClass(function(i, cls) { return cls; });
schedule.addClass(parentClass);
if (!alreadySelected) {
schedule.addClass(filterEnabledClass + ' ' + prefix + filter);
var filters = $.map(filter.split(' '), function (f) {
return prefix + f;
}).join(' ');
schedule.addClass(filterEnabledClass + ' ' + filters);
}
});
}(jQuery);