add sections, general cleanup

This commit is contained in:
j 2017-12-05 19:10:17 +01:00
parent 8c2c532ce7
commit abdc173cc1
11 changed files with 140 additions and 59 deletions

View File

@ -37,6 +37,9 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'content',
]
@ -121,7 +124,11 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
IMAGE_PREFIX = 'http://studio.camp/images/'
try:
from local_settings import *
except:
pass
pass

View File

@ -20,7 +20,19 @@ from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', views.index, name='index'),
url(r'^content/(?P<shortname>\w+)/$', views.content, name='content'),
url(r'^project/', views.project)
url(r'^.*index.php$', views.redirect_index, name='redirect_index'),
url(r'^.*event.php$', views.redirect_event, name='redirect_event'),
url(r'^projects/', views.projects, name='projects'),
url(r'^events/', views.events, name='events'),
url(r'^works/', views.works, name='works'),
url(r'^texts/', views.texts, name='texts'),
url(r'^about/', views.about, name='about'),
url(r'^contact/', views.contact, name='contact'),
url(r'^(?P<shortname>.+)/$', views.content, name='content'),
]

View File

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from django.urls import reverse
# Create your models here.
@ -84,6 +86,13 @@ class Content(models.Model):
managed = True
db_table = 'content'
@property
def image_url(self):
if self.image:
return settings.IMAGE_PREFIX + self.image
def get_absolute_url(self):
return reverse('content', kwargs={'shortname': self.shortname})
class ContentContent(models.Model):
@ -204,6 +213,9 @@ class Videos(models.Model): # not used
managed = False
db_table = 'videos'
def image_url(self):
return settings.IMAGE_PREFIX + self.image
class Views(models.Model):
name = models.CharField(max_length=255)

View File

@ -35,6 +35,8 @@ body, h1, h2, h3, h4, h5, h6 {
.sidebar-date {
text-transform: uppercase;
font-size: 0.7em;
font-weight: bold;
color: #ef4e5c;
}
.special-column {

View File

@ -18,13 +18,13 @@
<div class="off-canvas position-right" id="offCanvasRight" data-off-canvas data-position="right">
<ul class="vertical-menu">
<li>HOME</li>
<li>ABOUT</li>
<li><a href="/project">PROJECTS</a></li>
<li>EVENTS</li>
<li>WORKS</li>
<li>TEXTS</li>
<li>CONTACT</li>
<li><a href="{% url 'index' %}">HOME</a></li>
<li><a href="{% url 'about' %}">ABOUT</a></li>
<li><a href="{% url 'projects' %}">PROJECTS</a></li>
<li><a href="{% url 'events' %}">EVENTS</a></li>
<li><a href="{% url 'works' %}">WORKS</a></li>
<li><a href="{% url 'texts' %}">TEXTS</a></li>
<li><a href="{% url 'contact' %}">CONTACT</a></li>
</ul>
</div>
@ -43,12 +43,8 @@
{% load static %}
<script src="{% static "js/jquery.js" %}"></script>
<script src="{% static "js/app.js" %}"></script>
<script src="{% static "js/foundation.js" %}"></script>
<script src="{% static "js/app.js" %}"></script>
<script src="{% static "js/what-input.js" %}"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
</html>

View File

@ -4,11 +4,11 @@
{% block content %}
<img src="http://camputer.org/images/{{ content.image }}" width="75%">
<img src="{{ content.image_url }}" width="75%">
<div class="content_detail">
<h1>{{ content.title }}</h1>
<h4>{{ content.header|safe }} </h4>
<p>{{ content.body|safe }}</p>
</div>
{% endblock %}
{% endblock %}

View File

@ -7,14 +7,12 @@
{% for content in latest_content_list %}
{% if forloop.counter == 3 %}
<div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{content.image}}">
<img src="{{ content.image_url }}">
<div class="index-text">
<h4><a href="/content/{{ content.shortname }}/">{{content.title}} </a></h4>
<h6>Tate Modern <br />
29th March, 2017, 7:00 pm <br />
South Tank <br /> </h6>
<p> {{content.body|striptags|truncatechars:250}} <a href="/content/{{ content.shortname }}">read more</a> </p>
<h4><a href="{{ content.get_absolute_url }}">{{content.title}}</a></h4>
<p>
{{content.body|striptags|truncatechars:250}} <a href="{{ content.get_absolute_url }}">read more</a>
</p>
</div>
{% endif %}
{% endfor %}
@ -27,12 +25,12 @@
{% for content in latest_content_list %}
<div class="row right-items">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ content.image }}">
<img src="{{ content.image_url }}">
</div>
<div class="small-6 columns">
<a href="/content/{{ content.shortname }}/" class="sidebar-title">{{ content.title }}</a>
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} </b></font> <br/>
We will add a place to fill this text </h6>
<a href="{{ content.get_absolute_url }}" class="sidebar-title">{{ content.title }}</a>
<h6 class="sidebar-date">{{ content.datestart }}</h6>
{{ conntent.header }}
</div>
</div>
{% endfor %}
@ -42,4 +40,4 @@
</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -1,23 +0,0 @@
{% extends 'base.html' %}
{% block content %}
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4"> Upcoming Events </h4>
<div class="row">
{% for content in content %}
<div class="row right-items">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ content.image }}">
</div>
<div class="small-6 columns">
<a href="/content/{{ content.shortname }}/" class="sidebar-title">{{ content.title }}</a>
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} </b></font> <br/>
We will add a place to fill this text </h6>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,22 @@
{% extends 'base.html' %}
{% block content %}
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4">{{ title }}</h4>
<div class="row">
{% for content in content %}
<div class="row right-items">
<div class="small-6 columns">
<img src="{{ content.image_url }}">
</div>
<div class="small-6 columns">
<a href="{{ content.get_absolute_url }}" class="sidebar-title">{{ content.title }}</a>
<h6 class="sidebar-date">{{ content.datestart }}</h6>
{{content.header|striptags|truncatechars:150|safe}} <a href="{{ content.get_absolute_url }}">read more</a>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse
from .models import Content
# Create your views here.
def index(request):
latest_content_list = Content.objects.order_by('-datestart')[:5]
@ -12,9 +13,62 @@ def index(request):
return render(request, 'index.html', context)
def content(request, shortname):
content = get_object_or_404(Content, shortname = shortname)
content = get_object_or_404(Content, shortname=shortname)
return render(request, 'detail.html', {'content': content})
def project(request):
content = Content.objects.filter(type=3)
return render(request, 'project.html', {'content': content})
def projects(request):
content = Content.objects.filter(type__name='ongoing').exclude(shortname='').order_by('-datestart')
return render(request, 'projects.html', {
'content': content,
'title': 'Projects'
})
def events(request):
content = Content.objects.filter(type__name='events').exclude(shortname='')
content = Content.objects.filter(type__name='events').exclude(shortname='').order_by('-datestart')
return render(request, 'projects.html', {
'content': content,
'title': 'Upcoming Events'
})
def works(request):
content = Content.objects.filter(type__name='works').exclude(shortname='').order_by('-datestart')
return render(request, 'projects.html', {
'content': content,
'title': 'Works'
})
def texts(request):
content = Content.objects.filter(type__name='texts').exclude(shortname='')
return render(request, 'projects.html', {
'content': content,
'title': 'Texts'
})
def about(request):
content = get_object_or_404(Content, shortname='about')
return render(request, 'detail.html', {'content': content})
def contact(request):
content = get_object_or_404(Content, shortname='contact')
return render(request, 'detail.html', {'content': content})
def redirect_index(request):
segment = request.GET.get('show')
if segment == 'pastevents':
return redirect(reverse('works'))
elif segment == 'contact':
return redirect(reverse('contact'))
return redirect(reverse('index'))
def redirect_event(request):
shortname = request.GET.get('this')
if shortname:
return redirect(reverse('content', kwargs={'shortname': shortname}))
id = request.GET.get('id')
if id:
content = get_object_or_404(Content, id=id)
return redirect(reverse('content', kwargs={'shortname': content.shortname}))
return redirect(reverse('events'))

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
django