-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
204 changed files
with
10,474 additions
and
5,485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
python/cac_tripplanner/cms/migrations/0010_auto_20170201_1527.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import cms.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('CMS', '0009_auto_20150515_1248'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='article', | ||
name='narrow_image', | ||
field=models.ImageField(help_text=b'The small image. Will be displayed at 310x218.', null=True, upload_to=cms.models.generate_filename), | ||
), | ||
migrations.AlterField( | ||
model_name='article', | ||
name='wide_image', | ||
field=models.ImageField(help_text=b'The large image. Will be displayed at 680x200.', null=True, upload_to=cms.models.generate_filename), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,55 @@ | ||
import json | ||
from random import shuffle | ||
|
||
from django.conf import settings | ||
from django.core.urlresolvers import reverse | ||
from django.http import HttpResponse | ||
from django.shortcuts import render, get_object_or_404 | ||
from django.views.generic import View | ||
|
||
from .models import AboutFaq, Article | ||
from destinations.models import Destination | ||
from cac_tripplanner.settings import FB_APP_ID, HOMEPAGE_RESULTS_LIMIT, DEBUG | ||
|
||
|
||
def home(request): | ||
|
||
# get randomized community profile | ||
community_profile = Article.profiles.random() | ||
|
||
# get randomized tips and tricks | ||
tips_and_tricks = Article.tips.random() | ||
|
||
# get a few randomized destinations | ||
destination_ids = list(Destination.objects.published().values_list('id', flat=True)) | ||
shuffle(destination_ids) | ||
destinations = Destination.objects.filter(id__in=destination_ids[:4]) | ||
|
||
context = dict(community_profile=community_profile, | ||
tips_and_tricks=tips_and_tricks, | ||
destinations=destinations, | ||
fb_app_id=FB_APP_ID, | ||
debug=DEBUG) | ||
return render(request, 'home.html', context=context) | ||
|
||
DEFAULT_CONTEXT = { | ||
'debug': settings.DEBUG, | ||
'fb_app_id': settings.FB_APP_ID, | ||
'routing_url': settings.ROUTING_URL | ||
} | ||
|
||
def about_faq(request, slug): | ||
page = get_object_or_404(AboutFaq.objects.all(), slug=slug) | ||
context = {'page': page, 'debug': DEBUG} | ||
context = dict(tab='about', page=page, **DEFAULT_CONTEXT) | ||
return render(request, 'about-faq.html', context=context) | ||
|
||
def learn_list(request): | ||
articles = Article.objects.published().order_by('-publish_date') | ||
context = dict(tab='info', articles=articles, **DEFAULT_CONTEXT) | ||
return render(request, 'learn-list.html', context=context) | ||
|
||
def community_profile_detail(request, slug): | ||
"""Profile/Article view | ||
:param slug: article slug to lookup profile | ||
""" | ||
community_profile = get_object_or_404(Article.profiles.published(), | ||
slug=slug) | ||
context = {'article': community_profile, 'debug': DEBUG} | ||
return render(request, 'community-profile-detail.html', context=context) | ||
def learn_detail(request, slug): | ||
article = get_object_or_404(Article.objects.published(), slug=slug) | ||
more_articles = Article.objects.published().order_by('-publish_date').exclude(pk=article.pk)[:3] | ||
context = dict(tab='info', article=article, more_articles=more_articles, **DEFAULT_CONTEXT) | ||
return render(request, 'learn-detail.html', context=context) | ||
|
||
|
||
def tips_and_tricks_detail(request, slug): | ||
"""Tips and tricks detail view | ||
:param slug: article slug to lookup tips and tricks | ||
""" | ||
tips_and_tricks = get_object_or_404(Article.tips.published(), | ||
slug=slug) | ||
context = {'article': tips_and_tricks, 'debug': DEBUG} | ||
return render(request, 'tips-and-tricks-detail.html', context=context) | ||
|
||
class AllArticles(View): | ||
""" API endpoint for the Articles model """ | ||
|
||
def get(self, request, *args, **kwargs): | ||
""" GET title, URL, and images for the 20 most recent articles that are published""" | ||
results = Article.objects.published().order_by('-publish_date')[:HOMEPAGE_RESULTS_LIMIT] | ||
|
||
# resolve full URLs to articles and their images | ||
response = [] | ||
for obj in results: | ||
article = {} | ||
article['wide_image'] = obj.wide_image.url | ||
article['narrow_image'] = obj.narrow_image.url | ||
article['title'] = obj.title | ||
if obj.content_type == 'prof': | ||
relative_url = reverse(community_profile_detail, args=[obj.slug]) | ||
else: | ||
relative_url = reverse(tips_and_tricks_detail, args=[obj.slug]) | ||
article['url'] = request.build_absolute_uri(relative_url) | ||
response.append(article) | ||
def serialize_article(self, request, article): | ||
return { | ||
'wide_image': article.wide_image.url, | ||
'narrow_image': article.narrow_image.url, | ||
'title': article.title, | ||
'url': request.build_absolute_uri(reverse(learn_detail, args=[article.slug])) | ||
} | ||
|
||
def get(self, request, *args, **kwargs): | ||
""" GET title, URL, and images for published articles """ | ||
try: | ||
limit = int(request.GET.get('limit')) | ||
except (ValueError, TypeError): | ||
limit = settings.HOMEPAGE_RESULTS_LIMIT | ||
|
||
results = Article.objects.published().order_by('-publish_date')[:limit] | ||
response = [self.serialize_article(request, article) for article in results] | ||
return HttpResponse(json.dumps(response), 'application/json') |
Binary file modified
BIN
+56.4 KB
(230%)
python/cac_tripplanner/default_media/half-square/BartramsGarden.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+51.5 KB
(210%)
python/cac_tripplanner/default_media/half-square/CamdenCountyEcoCenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+44.4 KB
(240%)
...tripplanner/default_media/half-square/FairmountWaterworksInterpretiveCenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6.36 KB
(110%)
python/cac_tripplanner/default_media/half-square/IndependenceSeaportMuseum.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+34.6 KB
(200%)
...n/cac_tripplanner/default_media/half-square/JohnHeinzNationalWildlifeRefuge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-37.8 KB
(66%)
python/cac_tripplanner/default_media/half-square/MillGroveAudubon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+30.6 KB
(180%)
python/cac_tripplanner/default_media/half-square/NJAcademyofAquaticSciences.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-28.1 KB
(76%)
python/cac_tripplanner/default_media/half-square/PalmyraCoveNaturePark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+16.1 KB
(130%)
...ripplanner/default_media/half-square/SchuylkillEnvironmentalEducationCenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+46.5 KB
(230%)
...ac_tripplanner/default_media/half-square/SchuylkillRiverGreenwayAssociation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-30.9 KB
(75%)
python/cac_tripplanner/default_media/half-square/StonyBrookMillstone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+31.1 KB
(160%)
...pplanner/default_media/half-square/TulpehakingNatureCenteratAbbottMarshland.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-55.5 KB
(35%)
python/cac_tripplanner/default_media/square/BartramsGarden.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-58.8 KB
(34%)
python/cac_tripplanner/default_media/square/CamdenCountyEcoCenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-16.9 KB
(57%)
.../cac_tripplanner/default_media/square/FairmountWaterworksInterpretiveCenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-83.2 KB
(19%)
python/cac_tripplanner/default_media/square/IndependenceSeaportMuseum.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-51 KB
(28%)
python/cac_tripplanner/default_media/square/JohnHeinzNationalWildlifeRefuge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-184 KB
(12%)
python/cac_tripplanner/default_media/square/MillGroveAudubon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-33.6 KB
(41%)
python/cac_tripplanner/default_media/square/NJAcademyofAquaticSciences.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-175 KB
(13%)
python/cac_tripplanner/default_media/square/PalmyraCoveNaturePark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-96.3 KB
(21%)
...cac_tripplanner/default_media/square/SchuylkillEnvironmentalEducationCenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-41.5 KB
(39%)
python/cac_tripplanner/default_media/square/SchuylkillRiverGreenwayAssociation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-208 KB
(12%)
python/cac_tripplanner/default_media/square/StonyBrookMillstone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-66.1 KB
(27%)
...c_tripplanner/default_media/square/TulpehakingNatureCenteratAbbottMarshland.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.