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

Home explore #1029

Merged
merged 5 commits into from Apr 28, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/storybase_story/forms.py
Expand Up @@ -3,6 +3,8 @@
from django import forms
from django.utils import translation

from haystack.forms import SearchForm

from tinymce.widgets import TinyMCE

from storybase.widgets import AdminLongTextInputWidget
Expand Down Expand Up @@ -99,3 +101,28 @@ class Meta:
mce_attrs={'theme': 'advanced', 'force_p_newlines': False, 'forced_root_block': '', 'theme_advanced_toolbar_location': 'top', 'plugins': 'table', 'theme_advanced_buttons3_add': 'tablecontrols'},
)
}


class StorySearchForm(SearchForm):
"""
A custom search that allows user to optionally search based on a
single topic and/or place ID.

"""
topic_id = forms.IntegerField(required=False)
place_id = forms.IntegerField(required=False)

def search(self):
sqs = super(StorySearchForm, self).search()

topic_id = self.cleaned_data.get('topic_id', None)

if topic_id is not None:
sqs = sqs.filter(topic_ids__in=[topic_id])

place_id = self.cleaned_data.get('place_id', None)

if place_id is not None:
sqs = sqs.filter(place_ids__in=[place_id])

return sqs
3 changes: 2 additions & 1 deletion apps/storybase_story/urls.py
Expand Up @@ -7,9 +7,10 @@
from storybase_story.views import (ExploreStoriesView,
StoryBuilderView, StoryDetailView, StoryViewerView,
StoryUpdateView, StoryShareView, StorySharePopupView,
StoryEmbedView, StoryEmbedPopupView)
StoryEmbedView, StoryEmbedPopupView, HomeView)

urlpatterns = patterns('',
url(r'^home/$', HomeView.as_view(), name='home'),
url(r'^build/$', StoryBuilderView.as_view(), name='story_builder'),
url(r'^build/(?P<story_id>[0-9a-f]{32,32})/$',
StoryBuilderView.as_view(), name='story_builder'),
Expand Down
10 changes: 10 additions & 0 deletions apps/storybase_story/views.py
Expand Up @@ -34,6 +34,16 @@
from storybase_user.views import Organization, Project


class HomeView(TemplateView):
template_name = 'homepage.html'

def get_context_data(self, **kwargs):
context = super(HomeView, self).get_context_data(**kwargs)
context['topics'] = Category.objects.all()
context['places'] = Place.objects.all()

return context

class ExploreStoriesView(TemplateView):
"""
A view that lets users filter a list of stories
Expand Down
6 changes: 3 additions & 3 deletions search_urls.py
@@ -1,9 +1,9 @@
from django.conf.urls import patterns, url
from haystack.forms import SearchForm
from django.conf.urls import patterns, url
from storybase_story.forms import StorySearchForm
from storybase.search.views import StorybaseSearchView

urlpatterns = patterns('haystack.views',
url(r'^$', StorybaseSearchView(
form_class=SearchForm
form_class=StorySearchForm
), name='haystack_search'),
)
23 changes: 11 additions & 12 deletions static2/css/styles.css
Expand Up @@ -121,27 +121,26 @@ body {
margin-top: 20px;
}


.explore {

min-height: 300px;
}

.explore .title {
color: white;
}

.super-search {
margin: 100px;
}

.super-search input, .super-search button {
height: 90px;
font-size: 30px;
.explore .col-sm-4 {
text-align: center;
}

.explore .row {
margin-top: 34px;
}

.super-search button {
padding-left: 50px;
padding-right: 50px;
.explore .search-select, .explore .form-control {
width: 70%;
background-color: #ffffff;
height: 40px;
border-color: transparent;
border-radius: 5px;
}
74 changes: 50 additions & 24 deletions templates2/homepage.html
Expand Up @@ -12,7 +12,10 @@

<div class="about focus-text shadow-1">
<p>
Floodlight is a place where people can tell and share inspiring stories from the Metro Denver community. This easy tool allows users to create, post and share digital stories that include photo, video, data, and narrative, calling readers to action. It’s also a place to uncover connections between stories, and reach even higher levels of community impact.
Floodlight is a place where people can tell and share inspiring stories from the Metro Denver community.
This easy tool allows users to create, post and share digital stories that include photo, video, data,
and narrative, calling readers to action. It’s also a place to uncover connections between stories, and
reach even higher levels of community impact.
</p>

<a href="/en/build/">
Expand All @@ -22,40 +25,56 @@

</div>

<div class="container-fluid">
<div class="spotlight">
<h1 class="title">Spotlight</h1>

{% featured_stories %}

</div>
</div>

<div class="container-fluid orange-columns">

<div class="row explore">
<h1 class="title">Explore Floodlight</h1>

<div class="super-search">

<form action="{% url 'haystack_search' %}" method="get">
<div class="input-group">
<input name="q" type="text" class="form-control" autocomplete="off" />
<div class="input-group-btn">
<button class="btn btn-success btn-lg">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
<form action="{% url 'haystack_search' %}" method="get">
<div class="row">
<div class="col-sm-4">
<select class="search-select" name="topic_id">
<option value="">Topic</option>
{% for topic in topics %}
<option value="{{ topic.id }}">{{ topic.name }}</option>
{% endfor %}
<option value="">None</option>
</select>
</div>
<div class="col-sm-4">
<select class="search-select" name="place_id">
<option value="">Place</option>
{% for place in places %}
<option value="{{ place.id }}">{{ place.name }}</option>
{% endfor %}
<option value="">None</option>
</select>

</form>
</div>
<div class="col-sm-4">
<input required
name="q"
type="text"
class="form-control"
placeholder="Search by keyword"
autocomplete="off"/>
</div>

</div>
</div>

</form>
</div>
</div>

<div class="container-fluid">
<div class="spotlight">
<h1 class="title">Spotlight</h1>

{% featured_stories %}

</div>
</div>

</div>

<section style="display:none;" class="supporting-foundations">
Expand Down Expand Up @@ -111,7 +130,14 @@ <h5 class="title">{% trans "Supporting Foundations" %}</h5>

{% endblock content %}


{% block scripts %}
{{ block.super }}


{% endblock %}

{% block css %}
{{ block.super }}


{% endblock %}
{% endblock %}
5 changes: 5 additions & 0 deletions urls.py
Expand Up @@ -3,6 +3,7 @@
from django.contrib import admin
from django.conf import settings
from django.views.decorators.cache import cache_page
from django.views.generic.base import RedirectView

from tastypie.api import Api

Expand Down Expand Up @@ -72,10 +73,14 @@
(r'^accounts/', include('social_auth.urls')),
(r'^notices/', include('notification.urls')),

url(r'^$', RedirectView.as_view(url='/home/')),

# django CMS URLs
url(r'^', include('cms.urls')),

)


urlpatterns += patterns('',
url(r'^', include('storybase_story.widget_urls')),

Expand Down