Compare commits
5 Commits
25db5b2868
...
ff4e0b2325
Author | SHA1 | Date | |
---|---|---|---|
|
ff4e0b2325 | ||
|
b729ea7b51 | ||
|
25c4714072 | ||
|
f46154ddfd | ||
|
2b129a8596 |
|
@ -55,7 +55,7 @@ MIDDLEWARE = [
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
#'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'camp.urls'
|
ROOT_URLCONF = 'camp.urls'
|
||||||
|
@ -63,7 +63,9 @@ ROOT_URLCONF = 'camp.urls'
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': [
|
||||||
|
os.path.join(BASE_DIR, 'camp', 'templates')
|
||||||
|
],
|
||||||
'APP_DIRS': False,
|
'APP_DIRS': False,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
.slider1 {
|
||||||
|
display: none;
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ a:focus, a:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
.index-text p {
|
.index-text p {
|
||||||
text-align: justify;
|
//text-align: justify;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title-bar-right {
|
.title-bar-right {
|
||||||
|
|
|
@ -1386,7 +1386,8 @@
|
||||||
} else {
|
} else {
|
||||||
// if adaptiveHeight is true and next height is different from current height, animate to the new height
|
// if adaptiveHeight is true and next height is different from current height, animate to the new height
|
||||||
if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) {
|
if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) {
|
||||||
slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
|
// fails with slow connections
|
||||||
|
//slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
|
||||||
}
|
}
|
||||||
// if carousel and not infinite loop
|
// if carousel and not infinite loop
|
||||||
if (!slider.settings.infiniteLoop && slider.carousel && slider.active.last) {
|
if (!slider.settings.infiniteLoop && slider.carousel && slider.active.last) {
|
||||||
|
@ -1432,6 +1433,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
|
if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
|
||||||
|
if (!slider.working) {
|
||||||
|
el.redrawSlider()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -143,10 +143,25 @@ class Content(models.Model):
|
||||||
def typefilter(self):
|
def typefilter(self):
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
|
def admin_thumbnail_(self):
|
||||||
|
src = None
|
||||||
|
if self.photo:
|
||||||
|
src = self.photo.get_thumbnail_url()
|
||||||
|
if self.image:
|
||||||
|
if self.image.startswith('http') or self.image.startswith('/'):
|
||||||
|
src = self.image
|
||||||
|
else:
|
||||||
|
src = settings.IMAGE_PREFIX + self.image
|
||||||
|
if src:
|
||||||
|
return mark_safe(u'<a href="{}"><img src="{}"></a>'.format(self.get_absolute_url(), src))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image_url(self):
|
def image_url(self):
|
||||||
if self.photo:
|
if self.photo:
|
||||||
return self.photo.get_display_url()
|
url = self.photo.image.url
|
||||||
|
if not url.lower().endswith('.gif'):
|
||||||
|
url = self.photo.get_display_url()
|
||||||
|
return url
|
||||||
if self.image:
|
if self.image:
|
||||||
if self.image.startswith('http') or self.image.startswith('/'):
|
if self.image.startswith('http') or self.image.startswith('/'):
|
||||||
return self.image
|
return self.image
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
{% load available_content%}
|
{% load available_content static %}
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html class="no-js" lang="en">
|
<html class="no-js" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
{% block head %}
|
||||||
<title>Studio CAMP</title>
|
<title>Studio CAMP</title>
|
||||||
|
{% endblock %}
|
||||||
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
|
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
|
||||||
{% load static %}
|
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/jquery.bxslider.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "css/jquery.bxslider.css" %}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/main.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "css/main.css" %}">
|
||||||
|
@ -49,14 +50,36 @@
|
||||||
<script src="{% static "js/foundation.js" %}"></script>
|
<script src="{% static "js/foundation.js" %}"></script>
|
||||||
<script src="{% static "js/app.js" %}"></script>
|
<script src="{% static "js/app.js" %}"></script>
|
||||||
<script src="{% static "js/what-input.js" %}"></script>
|
<script src="{% static "js/what-input.js" %}"></script>
|
||||||
<script src="{% static "js/jquery.bxslider.js" %}"></script>
|
<script src="{% static "js/jquery.bxslider.js" %}?2"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
var startSlide = 0;
|
||||||
slider = $('.slider1').bxSlider({
|
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
||||||
|
startSlide = parseInt(document.location.hash.slice(1)) - 1
|
||||||
|
}
|
||||||
|
function loadSlideshow() {
|
||||||
|
$('a.original-link').bind('touchstart MSPointerDown pointerdown', function(event) {
|
||||||
|
event.stopPropagation()
|
||||||
|
});
|
||||||
|
$('a.original-link').on({
|
||||||
|
mousedown: function(event) {
|
||||||
|
event.stopPropagation()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
slider = $('.slider1').show().bxSlider({
|
||||||
|
startSlide: startSlide,
|
||||||
|
preloadImages: 'all',
|
||||||
adaptiveHeight : true,
|
adaptiveHeight : true,
|
||||||
pager : false,
|
pager : false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var images = $('.slider1 img'), count = images.length;
|
||||||
|
images.on({load: function(event) {
|
||||||
|
setTimeout(function() {
|
||||||
|
slider.resize()
|
||||||
|
slider.redrawSlider()
|
||||||
|
}, 100)
|
||||||
|
}})
|
||||||
|
|
||||||
document.querySelectorAll('.select-image').forEach(function(a) {
|
document.querySelectorAll('.select-image').forEach(function(a) {
|
||||||
a.onclick = function(event) {
|
a.onclick = function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -64,12 +87,21 @@
|
||||||
document.location.hash = '#' + this.dataset.id;
|
document.location.hash = '#' + this.dataset.id;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
||||||
var slide = parseInt(document.location.hash.slice(1))
|
var slide = parseInt(document.location.hash.slice(1))
|
||||||
if (slide) {
|
if (slide) {
|
||||||
slider.goToSlide(slide - 1)
|
slider.goToSlide(slide - 1)
|
||||||
|
slider.resize()
|
||||||
|
slider.redrawSlider()
|
||||||
|
setTimeout(function() {
|
||||||
|
slider.resize()
|
||||||
|
slider.redrawSlider()
|
||||||
|
}, 2000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$(document).keydown(function(e){
|
$(document).keydown(function(e){
|
||||||
if (e.keyCode == 39) // Right arrow
|
if (e.keyCode == 39) // Right arrow
|
||||||
|
@ -82,8 +114,9 @@
|
||||||
slider && slider.goToPrevSlide();
|
slider && slider.goToPrevSlide();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
$(document).ready(loadSlideshow);
|
||||||
</script>
|
</script>
|
||||||
{% block end %}
|
{% block end %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
7
content/templates/content-header.html
Normal file
7
content/templates/content-header.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
<title>{{ content.title }} - Studio CAMP</title>
|
||||||
|
<meta name="title" content="{{ content.title }}"/>
|
||||||
|
<meta property="og:title" content="{{ content.title }}"/>
|
||||||
|
<meta content="https://studio.camp{{ content.image_url }}" name="thumbnail"/>
|
||||||
|
<meta content="https://studio.camp{{ content.image_url }}" name="image_src"/>
|
||||||
|
<meta property="og:image" content="https://studio.camp{{ content.image_url }}"/>
|
|
@ -1,4 +1,7 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% block head %}
|
||||||
|
{% include "content-header.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "edit.html" %}
|
{% include "edit.html" %}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% block head %}
|
||||||
|
{% include "content-header.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "featured.html" %}
|
{% include "featured.html" %}
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
<ul class="slider1">
|
<ul class="slider1">
|
||||||
{% for photo in gallery.public %}
|
{% for photo in gallery.public %}
|
||||||
<li id="slide-{{photo.slug}}">
|
<li id="slide-{{photo.slug}}">
|
||||||
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}">
|
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}" loading="lazy">
|
||||||
<p>
|
<p>
|
||||||
{{ photo.caption|safe }}
|
{{ photo.caption|safe }}
|
||||||
{% if photo.caption %}<br>{%endif%}
|
{% if photo.caption %}<br>{%endif%}
|
||||||
<a href="{{ photo.image.url }}" target="_blank" >Link to original file</a>
|
<a href="{{ photo.image.url }}" class="original-link" target="_blank" >Link to original file</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<p>
|
<p>
|
||||||
{{ object.caption|safe }}
|
{{ object.caption|safe }}
|
||||||
{% if object.caption %}<br>{%endif%}
|
{% if object.caption %}<br>{%endif%}
|
||||||
<a href="{{ object.image.url }}" target="_blank" >Link to original file</a>
|
<a href="{{ object.image.url }}" class="original-link" target="_blank" >Link to original file</a>
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for gallery in object.public_galleries %}
|
{% for gallery in object.public_galleries %}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django import template
|
from django import template
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.html import mark_safe
|
||||||
|
|
||||||
from ..models import Content
|
from ..models import Content
|
||||||
|
|
||||||
|
@ -18,3 +19,27 @@ def available_content():
|
||||||
type.upper()
|
type.upper()
|
||||||
])
|
])
|
||||||
return sections
|
return sections
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def admin_thumbnail(row):
|
||||||
|
from photologue.models import Photo
|
||||||
|
p = None
|
||||||
|
if 'for="id_photos_' in row.get('label_for'):
|
||||||
|
try:
|
||||||
|
p = Photo.objects.get(pk=row['option_value'])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif 'for="id_related_content_' in row.get('label_for'):
|
||||||
|
try:
|
||||||
|
p = Content.objects.get(pk=row['option_value'])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
if p:
|
||||||
|
try:
|
||||||
|
return mark_safe(p.admin_thumbnail() + ' ')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return ''
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -9,6 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.core.mail import EmailMessage
|
from django.core.mail import EmailMessage
|
||||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||||
from django.db.models import Q, Count
|
from django.db.models import Q, Count
|
||||||
|
from django.db.models.functions import Coalesce
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
from django.shortcuts import get_object_or_404, render, redirect
|
from django.shortcuts import get_object_or_404, render, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -23,14 +24,24 @@ from . import forms
|
||||||
|
|
||||||
ITEMS_PER_PAGE = 30
|
ITEMS_PER_PAGE = 30
|
||||||
|
|
||||||
|
def get_events(base):
|
||||||
|
now = datetime.now() - timedelta(hours=24)
|
||||||
|
now = datetime.now().date()
|
||||||
|
upcoming_events = base.filter(datestart__gte=now).order_by('datestart')[:12]
|
||||||
|
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now)[:12]
|
||||||
|
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now))
|
||||||
|
#past_events.annotate(datesort=Coalesce('dateend', 'datestart')).order_by('-datesort')[:12]
|
||||||
|
past_events = past_events.order_by('-datestart')[:12]
|
||||||
|
#past_events = list(past_events)
|
||||||
|
#past_events.sort(key=lambda event: event.dateend if event.dateend else event.datestart, reverse=True)
|
||||||
|
return upcoming_events, ongoing_events, past_events
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
now = datetime.now()
|
|
||||||
display_events = ['news', 'events']
|
display_events = ['news', 'events']
|
||||||
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
|
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
|
||||||
base = base.filter(published=True)
|
base = base.filter(published=True)
|
||||||
upcoming_events = base.filter(datestart__gte=now)[:12]
|
upcoming_events, ongoing_events, past_events = get_events(base)
|
||||||
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now)[:12]
|
|
||||||
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now))[:12]
|
|
||||||
|
|
||||||
homepage = Content.objects.filter(type__name='homepage').order_by('-datestart')[:1]
|
homepage = Content.objects.filter(type__name='homepage').order_by('-datestart')[:1]
|
||||||
context = {
|
context = {
|
||||||
|
@ -73,7 +84,7 @@ def section_index(request, section, max_length=10):
|
||||||
def content_years(content):
|
def content_years(content):
|
||||||
years = [
|
years = [
|
||||||
year['year'].year
|
year['year'].year
|
||||||
for year in content.annotate(year=TruncYear('datestart')).values('year').annotate(count=Count('shortname')).order_by('-year')
|
for year in content.exclude(datestart=None).annotate(year=TruncYear('datestart')).values('year').annotate(count=Count('shortname')).order_by('-year')
|
||||||
]
|
]
|
||||||
return years
|
return years
|
||||||
|
|
||||||
|
@ -81,9 +92,10 @@ def filter_by_years(content, year):
|
||||||
years = content_years(content)
|
years = content_years(content)
|
||||||
if year.isdigit():
|
if year.isdigit():
|
||||||
year = int(year)
|
year = int(year)
|
||||||
else:
|
elif years:
|
||||||
year = years[0]
|
year = years[0]
|
||||||
content = content.filter(datestart__gte='%s-01-01' % year, datestart__lt='%s-01-01' % (year+1))
|
if year:
|
||||||
|
content = content.filter(datestart__gte='%04d-01-01' % year, datestart__lt='%04d-01-01' % (year+1))
|
||||||
return {
|
return {
|
||||||
'content': content,
|
'content': content,
|
||||||
'year': year,
|
'year': year,
|
||||||
|
@ -124,7 +136,6 @@ def section_list(request, section):
|
||||||
return render(request, 'results.html', context)
|
return render(request, 'results.html', context)
|
||||||
|
|
||||||
def event(request):
|
def event(request):
|
||||||
now = datetime.now()
|
|
||||||
display_events = ['events', 'news']
|
display_events = ['events', 'news']
|
||||||
featured = Content.objects.filter(type__name='events', featured=True).order_by('-datestart')[:1]
|
featured = Content.objects.filter(type__name='events', featured=True).order_by('-datestart')[:1]
|
||||||
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
|
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
|
||||||
|
@ -132,9 +143,7 @@ def event(request):
|
||||||
if featured:
|
if featured:
|
||||||
base = base.exclude(pk=featured[0].pk)
|
base = base.exclude(pk=featured[0].pk)
|
||||||
|
|
||||||
upcoming_events = base.filter(datestart__gt=now).order_by('-datestart')
|
upcoming_events, ongoing_events, past_events = get_events(base)
|
||||||
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now).order_by('-datestart')
|
|
||||||
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now)).order_by('-datestart')[:10]
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'upcoming_events': upcoming_events,
|
'upcoming_events': upcoming_events,
|
||||||
|
@ -150,6 +159,7 @@ def get_related_content(types, current=None, max_length=10):
|
||||||
latest_content_list = Content.objects.filter(type__name__in=types).order_by('-datestart')
|
latest_content_list = Content.objects.filter(type__name__in=types).order_by('-datestart')
|
||||||
if current:
|
if current:
|
||||||
latest_content_list = latest_content_list.exclude(pk=current.pk)
|
latest_content_list = latest_content_list.exclude(pk=current.pk)
|
||||||
|
latest_content_list = latest_content_list.exclude(pk__in=current.related_content.all())
|
||||||
latest_content_list = latest_content_list.filter(published=True)
|
latest_content_list = latest_content_list.filter(published=True)
|
||||||
more = latest_content_list.count() > max_length
|
more = latest_content_list.count() > max_length
|
||||||
latest_content_list = latest_content_list[:max_length]
|
latest_content_list = latest_content_list[:max_length]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user