Compare commits

..

No commits in common. "ff4e0b23254b6b80b6354e29c96147693d0c60b0" and "25db5b28683eb22f9ee9225d4eef5b4c21f82fbc" have entirely different histories.

13 changed files with 28 additions and 133 deletions

View File

@ -55,7 +55,7 @@ MIDDLEWARE = [
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
#'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'camp.urls'
@ -63,9 +63,7 @@ ROOT_URLCONF = 'camp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'camp', 'templates')
],
'DIRS': [],
'APP_DIRS': False,
'OPTIONS': {
'context_processors': [

View File

@ -1,4 +0,0 @@
.slider1 {
display: none;
}

View File

@ -66,7 +66,7 @@ a:focus, a:hover {
}
.index-text p {
//text-align: justify;
text-align: justify;
}
.title-bar-right {

View File

@ -1386,8 +1386,7 @@
} else {
// 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()) {
// fails with slow connections
//slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
}
// if carousel and not infinite loop
if (!slider.settings.infiniteLoop && slider.carousel && slider.active.last) {
@ -1433,9 +1432,6 @@
}
}
if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
if (!slider.working) {
el.redrawSlider()
}
};
/**

View File

@ -143,25 +143,10 @@ class Content(models.Model):
def typefilter(self):
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
def image_url(self):
if self.photo:
url = self.photo.image.url
if not url.lower().endswith('.gif'):
url = self.photo.get_display_url()
return url
return self.photo.get_display_url()
if self.image:
if self.image.startswith('http') or self.image.startswith('/'):
return self.image

View File

@ -1,14 +1,13 @@
{% load available_content static %}
{% load available_content%}
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% block head %}
<title>Studio CAMP</title>
{% endblock %}
<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/jquery.bxslider.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "css/main.css" %}">
@ -50,36 +49,14 @@
<script src="{% static "js/foundation.js" %}"></script>
<script src="{% static "js/app.js" %}"></script>
<script src="{% static "js/what-input.js" %}"></script>
<script src="{% static "js/jquery.bxslider.js" %}?2"></script>
<script src="{% static "js/jquery.bxslider.js" %}"></script>
<script type="text/javascript">
var startSlide = 0;
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',
$(document).ready(function(){
slider = $('.slider1').bxSlider({
adaptiveHeight : true,
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) {
a.onclick = function(event) {
event.preventDefault();
@ -87,21 +64,12 @@
document.location.hash = '#' + this.dataset.id;
};
});
/*
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
var slide = parseInt(document.location.hash.slice(1))
if (slide) {
slider.goToSlide(slide - 1)
slider.resize()
slider.redrawSlider()
setTimeout(function() {
slider.resize()
slider.redrawSlider()
}, 2000)
}
}
*/
$(document).keydown(function(e){
if (e.keyCode == 39) // Right arrow
@ -115,8 +83,7 @@
return false;
}
});
}
$(document).ready(loadSlideshow);
});
</script>
{% block end %}
{% endblock %}

View File

@ -1,7 +0,0 @@
<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 }}"/>

View File

@ -1,7 +1,4 @@
{% extends 'base.html' %}
{% block head %}
{% include "content-header.html" %}
{% endblock %}
{% block content %}
{% include "edit.html" %}

View File

@ -1,7 +1,5 @@
{% extends 'base.html' %}
{% block head %}
{% include "content-header.html" %}
{% endblock %}
{% block content %}
{% include "featured.html" %}

View File

@ -13,11 +13,11 @@
<ul class="slider1">
{% for photo in gallery.public %}
<li id="slide-{{photo.slug}}">
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}" loading="lazy">
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}">
<p>
{{ photo.caption|safe }}
{% if photo.caption %}<br>{%endif%}
<a href="{{ photo.image.url }}" class="original-link" target="_blank" >Link to original file</a>
<a href="{{ photo.image.url }}" target="_blank" >Link to original file</a>
</p>
</li>

View File

@ -10,7 +10,7 @@
<p>
{{ object.caption|safe }}
{% if object.caption %}<br>{%endif%}
<a href="{{ object.image.url }}" class="original-link" target="_blank" >Link to original file</a>
<a href="{{ object.image.url }}" target="_blank" >Link to original file</a>
</p>
<ul>
{% for gallery in object.public_galleries %}

View File

@ -1,6 +1,5 @@
from django import template
from django.urls import reverse
from django.utils.html import mark_safe
from ..models import Content
@ -19,27 +18,3 @@ def available_content():
type.upper()
])
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 ''

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from datetime import datetime, timedelta
from datetime import datetime
import re
from django.conf import settings
@ -9,7 +9,6 @@ from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import EmailMessage
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q, Count
from django.db.models.functions import Coalesce
from django.http import HttpResponse, Http404
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse
@ -24,24 +23,14 @@ from . import forms
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):
now = datetime.now()
display_events = ['news', 'events']
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
base = base.filter(published=True)
upcoming_events, ongoing_events, past_events = get_events(base)
upcoming_events = base.filter(datestart__gte=now)[: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))[:12]
homepage = Content.objects.filter(type__name='homepage').order_by('-datestart')[:1]
context = {
@ -84,7 +73,7 @@ def section_index(request, section, max_length=10):
def content_years(content):
years = [
year['year'].year
for year in content.exclude(datestart=None).annotate(year=TruncYear('datestart')).values('year').annotate(count=Count('shortname')).order_by('-year')
for year in content.annotate(year=TruncYear('datestart')).values('year').annotate(count=Count('shortname')).order_by('-year')
]
return years
@ -92,10 +81,9 @@ def filter_by_years(content, year):
years = content_years(content)
if year.isdigit():
year = int(year)
elif years:
else:
year = years[0]
if year:
content = content.filter(datestart__gte='%04d-01-01' % year, datestart__lt='%04d-01-01' % (year+1))
content = content.filter(datestart__gte='%s-01-01' % year, datestart__lt='%s-01-01' % (year+1))
return {
'content': content,
'year': year,
@ -136,6 +124,7 @@ def section_list(request, section):
return render(request, 'results.html', context)
def event(request):
now = datetime.now()
display_events = ['events', 'news']
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')
@ -143,7 +132,9 @@ def event(request):
if featured:
base = base.exclude(pk=featured[0].pk)
upcoming_events, ongoing_events, past_events = get_events(base)
upcoming_events = base.filter(datestart__gt=now).order_by('-datestart')
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 = {
'upcoming_events': upcoming_events,
@ -159,7 +150,6 @@ def get_related_content(types, current=None, max_length=10):
latest_content_list = Content.objects.filter(type__name__in=types).order_by('-datestart')
if current:
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)
more = latest_content_list.count() > max_length
latest_content_list = latest_content_list[:max_length]