This commit is contained in:
root 2017-12-18 12:54:04 +00:00
parent 268900b7b9
commit 8b9df9d8a0
24 changed files with 525 additions and 55059 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc *.pyc
local_settings.py local_settings.py
camp.json camp.json
*.swp

54831
camp.json

File diff suppressed because one or more lines are too long

View File

@ -18,9 +18,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')lzq#s+we0&7f=(@g)e2^9n@_fo5vz7l8q7py%5qx%_2dq-o!#'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
@ -138,13 +135,35 @@ STATIC_ROOT = ''
STATICFILES_DIRS = (os.path.join(SITE_ROOT, 'static'), ) STATICFILES_DIRS = (os.path.join(SITE_ROOT, 'static'), )
MARKDOWNX_MEDIA_PATH = os.path.abspath('camp/static/images') MARKDOWNX_MEDIA_PATH = os.path.join(BASE_ROOT, 'data/images')
MARKDOWNX_EDITOR_RESIZABLE = True MARKDOWNX_EDITOR_RESIZABLE = True
MEDIA_URL = '/static/images/' MEDIA_URL = '/images/'
MEDIA_ROOT = '/Users/vaishk/camp/camp/static/images/' MEDIA_ROOT = os.path.join(BASE_ROOT, 'data/images')
IMAGE_PREFIX = 'http://studio.camp/images/'
try: try:
from local_settings import * from local_settings import *
except: except:
pass pass
# Make this unique, creates random key first at first time.
try:
SECRET_KEY
except NameError:
SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
try:
SECRET_KEY = open(SECRET_FILE).read().strip()
except IOError:
try:
from django.utils.crypto import get_random_string
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
SECRET_KEY = get_random_string(50, chars)
secret = open(SECRET_FILE, 'w')
secret.write(SECRET_KEY)
secret.close()
except IOError:
Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE)

View File

@ -13,28 +13,42 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include 1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
""" """
from django.conf.urls import url, include
from markdownx import urls as markdownx
from content import views
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings from django.conf import settings
from django.conf.urls import url, include
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import RedirectView
from markdownx import urls as markdownx
from photologue.views import GalleryListView from photologue.views import GalleryListView
from content import views
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'^$', views.index, name='index'), url(r'^$', views.index, name='index'),
url(r'^.*index.php$', views.redirect_index, name='redirect_index'),
url(r'^.*event.php$', views.redirect_event, name='redirect_event'),
url(r'^.*(/images/.*)$', views.redirect_images, name='redirect_images'),
url(r'directions.html', RedirectView.as_view(url='/directions/')),
url(r'campstudio.html', RedirectView.as_view(url='/directions/')),
url(r'^events/(?P<shortname>\w+)/$', views.events, name='events'), url(r'^events/(?P<shortname>\w+)/$', views.events, name='events'),
url(r'^projects/(?P<shortname>\w+)/$', views.projects, name='projects'), url(r'^projects/(?P<shortname>\w+)/$', views.projects, name='projects'),
url(r'^works/(?P<shortname>\w+)/$', views.works, name='works'), url(r'^works/(?P<shortname>\w+)/$', views.works, name='works'),
url(r'^texts/(?P<shortname>\w+)/$', views.texts, name='texts'), url(r'^texts/(?P<shortname>\w+)/$', views.texts, name='texts'),
url(r'^work/', views.work), url(r'^works/$', views.work),
url(r'^project/', views.project), url(r'^projects/$', views.project),
url(r'^event/', views.event), url(r'^events/$', views.event),
url(r'^text/', views.text), url(r'^texts/$', views.text),
url(r'^search/$', views.search),
url(r'^markdownx/', include(markdownx)), url(r'^markdownx/', include(markdownx)),
url(r'^photologue/', include('photologue.urls', namespace='photologue')), url(r'^photologue/', include('photologue.urls', namespace='photologue')),
url(r'^gallerylist/$', GalleryListView.as_view(), name='gallery-list'), url(r'^gallerylist/$', GalleryListView.as_view(), name='gallery-list'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + [
url(r'^(?P<shortname>\w+)/$', views.page, name='page')
]

View File

@ -14,6 +14,7 @@ from photologue.models import Gallery
class ContentParentsInline(admin.TabularInline): class ContentParentsInline(admin.TabularInline):
model = ContentContent model = ContentContent
fk_name = 'contentid2' fk_name = 'contentid2'
raw_id_fields = ['contentid1']
class ImagesInline(admin.StackedInline): class ImagesInline(admin.StackedInline):
model = Image model = Image
@ -48,9 +49,9 @@ class GalleryAdmin(GalleryAdminDefault):
class ContentAdmin(admin.ModelAdmin): class ContentAdmin(admin.ModelAdmin):
save_on_top = True save_on_top = True
list_display = ('__unicode__', 'datestart', 'type') list_display = ('__unicode__', 'datestart', 'shortname', 'type')
list_filter = ['datestart', 'type'] list_filter = ['datestart', 'type']
search_fields = ['title', 'body', 'header'] search_fields = ['title', 'body', 'header', 'shortname']
inlines = [ContentParentsInline, ImagesInline, FileInline, LinkInline] inlines = [ContentParentsInline, ImagesInline, FileInline, LinkInline]
formfield_overrides = { formfield_overrides = {
models.TextField: {'widget': AdminMarkdownxWidget}, models.TextField: {'widget': AdminMarkdownxWidget},

View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2017-12-18 11:03
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('content', '0002_auto_20170621_0915'),
]
operations = [
migrations.AddField(
model_name='content',
name='teaser',
field=models.TextField(blank=True, null=True, validators=[django.core.validators.MaxLengthValidator(200)]),
),
migrations.AlterField(
model_name='content',
name='dateadded',
field=models.DateTimeField(auto_now_add=True, db_column='dateAdded'),
),
migrations.AlterField(
model_name='content',
name='datemodified',
field=models.DateTimeField(auto_now=True, db_column='dateModified', null=True),
),
migrations.AlterField(
model_name='content',
name='published',
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name='content',
name='view',
field=models.ForeignKey(blank=True, db_column='view', editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='content.Views'),
),
]

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2017-12-18 11:49
from __future__ import unicode_literals
from django.db import migrations, models
import markdownx.models
class Migration(migrations.Migration):
dependencies = [
('content', '0003_auto_20171218_1103'),
]
operations = [
migrations.AddField(
model_name='content',
name='featured',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='content',
name='header',
field=markdownx.models.MarkdownxField(blank=True, default='', null=True),
),
migrations.AlterField(
model_name='content',
name='published',
field=models.BooleanField(default=False),
),
]

View File

@ -1,8 +1,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from markdownx.models import MarkdownxField
from django.conf import settings
from django.core.validators import MaxLengthValidator
from django.db import models from django.db import models
from django.utils.html import mark_safe
from markdownx.models import MarkdownxField
from markdownx.utils import markdownify from markdownx.utils import markdownify
import ox
# Create your models here. # Create your models here.
@ -55,10 +61,11 @@ class Comments(models.Model): #not used
class Content(models.Model): class Content(models.Model):
type = models.ForeignKey("ContentTypes", db_column="type") type = models.ForeignKey("ContentTypes", db_column="type")
shortname = models.CharField(db_column='shortName', max_length=255, unique=True) # Field name made lowercase. shortname = models.CharField(db_column='shortName', max_length=255) # Field name made lowercase.
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
header = MarkdownxField() header = MarkdownxField(blank=True, null=True, default='')
body = MarkdownxField() body = MarkdownxField(blank=True, null=True, default='')
teaser = models.TextField(blank=True, null=True, validators=[MaxLengthValidator(200)])
schedule = models.TextField(blank=True, null=True) schedule = models.TextField(blank=True, null=True)
schedulebutton = models.CharField(db_column='scheduleButton', max_length=255, blank=True, null=True) # Field name made lowercase. schedulebutton = models.CharField(db_column='scheduleButton', max_length=255, blank=True, null=True) # Field name made lowercase.
optbtn2 = models.CharField(db_column='optBtn2', max_length=127, blank=True, null=True) # Field name made lowercase. optbtn2 = models.CharField(db_column='optBtn2', max_length=127, blank=True, null=True) # Field name made lowercase.
@ -70,10 +77,11 @@ class Content(models.Model):
postedby = models.CharField(db_column='postedBy', max_length=50, blank=True, null=True) # Field name made lowercase. postedby = models.CharField(db_column='postedBy', max_length=50, blank=True, null=True) # Field name made lowercase.
datestart = models.DateField(db_column='dateStart', blank=True, null=True) # Field name made lowercase. datestart = models.DateField(db_column='dateStart', blank=True, null=True) # Field name made lowercase.
dateend = models.DateField(db_column='dateEnd', blank=True, null=True) # Field name made lowercase. dateend = models.DateField(db_column='dateEnd', blank=True, null=True) # Field name made lowercase.
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. dateadded = models.DateTimeField(db_column='dateAdded', auto_now_add=True, editable=True) # Field name made lowercase.
datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True) # Field name made lowercase. datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True, auto_now=True) # Field name made lowercase.
published = models.IntegerField() published = models.BooleanField(default=False)
view = models.ForeignKey("Views", null=True, blank=True, db_column="view") featured = models.BooleanField(default=False)
view = models.ForeignKey("Views", null=True, blank=True, db_column="view", editable=False)
place = models.CharField(max_length=255, null=True, blank=True) place = models.CharField(max_length=255, null=True, blank=True)
parentid = models.IntegerField(null=True, db_column='parentID', blank=True) # Field name made lowercase. parentid = models.IntegerField(null=True, db_column='parentID', blank=True) # Field name made lowercase.
parents = models.ManyToManyField('Content', through='ContentContent', related_name= "children") parents = models.ManyToManyField('Content', through='ContentContent', related_name= "children")
@ -83,16 +91,40 @@ class Content(models.Model):
@property @property
def formatted_header(self): def formatted_header(self):
return markdownify(self.header) return mark_safe(markdownify(self.header))
@property @property
def formatted_body(self): def formatted_body(self):
return markdownify(self.body) return mark_safe(markdownify(self.body))
@property
def formatted_teaser(self):
if self.teaser:
value = self.teaser
elif self.header:
value = ox.strip_tags(ox.decode_html(self.header))[:100]
else:
value = ''
return mark_safe(value)
@property @property
def typefilter(self): def typefilter(self):
return self.type return self.type
@property
def image_url(self):
if self.image:
return settings.IMAGE_PREFIX + self.image
def get_absolute_url(self):
if self.shortname:
section = self.type.name
if section == 'news':
section = 'events'
if section == 'page':
return '/' + self.shortname
return '/%s/%s' %(section, self.shortname)
class Meta: class Meta:
managed = True managed = True

View File

@ -19,13 +19,13 @@
<div class="off-canvas position-right" id="offCanvasRight" data-off-canvas data-position="right"> <div class="off-canvas position-right" id="offCanvasRight" data-off-canvas data-position="right">
<ul class="vertical-menu"> <ul class="vertical-menu">
<li><a href="http://127.0.0.1:8000/">HOME</a></li> <li><a href="/">HOME</a></li>
<li>ABOUT</li> <li><a href="/about">ABOUT</a></li>
<li><a href="/project">PROJECTS</a></li> <li><a href="/projects">PROJECTS</a></li>
<li><a href="/event">EVENTS</a></li> <li><a href="/events">EVENTS</a></li>
<li><a href="/work">WORKS</a></li> <li><a href="/works">WORKS</a></li>
<li>TEXTS</li> <li><a href="/texts">TEXTS</a></li>
<li>CONTACT</li> <li><a href="/contact">CONTACT</a></li>
</ul> </ul>
</div> </div>
@ -43,13 +43,10 @@
{% load static %} {% load static %}
<script src="{% static "js/jquery.js" %}"></script> <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/foundation.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" %}"></script>
<script>
$(document).foundation();
</script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
var slider = $('.slider1').bxSlider({ var slider = $('.slider1').bxSlider({
@ -74,4 +71,4 @@
</script> </script>
</body> </body>
</html> </html>

View File

@ -2,51 +2,20 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% block content %}
{% include "featured.html" %}
{% for content in featured %}
<div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{content.image}}">
<div class="index-text">
<h4><a href="/{{content.type}}/{{ content.shortname }}/" class="big-title">{{content.title}} </a></h4>
<h6 class="big-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} </b></font> <br/>
Camp Roof </h6>
<p> {{content.body|striptags|truncatechars:250}} <a href="/{{content.type}}/{{ content.shortname }}">read more</a> </p>
</div>
{% endfor %}
</div>
<div class="large-4 medium-4 columns"> <div class="large-4 medium-4 columns">
{% if upcoming_events.exists %}
<h4 class="sidebar-h4"> Upcoming Events </h4> <h4 class="sidebar-h4"> Upcoming Events </h4>
<div class="row"> {% include "event_preview.html" with events=upcoming_events %}
{% endif %}
{% for content in latest_content_list %} {% if ongoing_events.exists %}
{% if content.type_id == 1 %} <h4 class="sidebar-h4"> Ongoing Events </h4>
{% include "event_preview.html" with events=ongoing_events %}
<div class="row right-items"> {% endif %}
<div class= "small-12 columns"> {% if past_events.exists %}
<h6> {{ content.title }} <br /> <h4 class="sidebar-h4"> Past Events </h4>
{{ content.formatted_header|safe }} {% include "event_preview.html" with events=past_events %}
</h6> {% endif %}
</div> </div>
</div> </div>
{% endif %} {% endblock %}
{% if content.type_id == 0 %}
<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.type}}/{{ 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>
{% endif %}
{% endfor %}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,36 @@
<div class="row">
{% for content in events %}
{% if content.type.name == 'news' %}
<div class="row right-items">
<div class= "small-12 columns">
<h6 class="sidebar-date">
<font color="#ef4e5c"> <b> {{content.datestart}} </b>
{{ content.title }} <br />
{{ content.formatted_header|striptags|safe }}
</font>
</h6>
</div>
</div>
{% elif content.type.name == 'events' %}
<div class="row right-items">
{% if content.image_url %}
<div class="small-6 columns">
<img src="{{ content.image_url }}">
</div>
{% endif %}
<div class="small-6 columns">
<a href="{{ content.get_absolute_url }}" class="sidebar-title">{{ content.title }}</a>
<h6 class="sidebar-date">
<font color="#ef4e5c">
<b>{{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %}</b>
</font>
{%if content.place %}<br>{{content.place}}{% endif %}
</h6>
<p> {{content.formatted_teaser}} </p>
</div>
</div>
{% endif %}
{% endfor %}
<br>
<br>
</div>

View File

@ -5,9 +5,11 @@
{% block content %} {% block content %}
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{events.image}}"> {% if events.image %}
<img src="{{events.image_url}}">
{% endif %}
<div class="index-text"> <div class="index-text">
<h4><a href="/{{events.type}}/{{ events.shortname }}/" class="big-title">{{events.title}} </a></h4> <h4><a href="{{ events.get_absolute_url }}/" class="big-title">{{events.title}} </a></h4>
<p> {{events.formatted_header|safe}} </p> <p> {{events.formatted_header|safe}} </p>
<p> {{events.formatted_body|safe}} </p> <p> {{events.formatted_body|safe}} </p>
{% if gallery %} {% if gallery %}
@ -29,12 +31,16 @@
{% for child in events.children.all %} {% for child in events.children.all %}
<div class="row related-row"> <div class="row related-row">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}"> <img src="{{ child.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<h6><a href="http://127.0.0.1:8000/{{child.type}}/{{child.shortname}}" class="sidebar-title"> {{child}} </a> </h6> <h6><a href="{{ child.get_absolute_url }}" class="sidebar-title"> {{child}} </a> </h6>
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ child.datestart }} {% if child.dateend %} - {{child.dateend}} {% endif %} </b></font> <br/> <h6 class="sidebar-date">
{{child.place}} </h6> <font color="#ef4e5c">
<b> {{ child.datestart }} {% if child.dateend %} - {{child.dateend}} {% endif %} </b>
</font>
{% if content.place %}<br/>{{content.place}}{% endif%}
</h6>
</div> </div>
</div> </div>
@ -47,12 +53,12 @@
<div class="row right-items"> <div class="row right-items">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ events.image }}"> <img src="{{ events.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<a href="/{{events.type}}/{{ events.shortname }}/" >{{ events.title }}</a> <a href="{{ events.get_absolute_url }}/" >{{ events.title }}</a>
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ events.datestart }} </b></font> <br/></h6> <h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ events.datestart }} </b></font> <br/></h6>
<p> {{events.header|striptags|truncatechars:200}} </p> <p> {{events.header|striptags|truncatechars:200|safe}} </p>
</div> </div>
</div> </div>
@ -62,4 +68,4 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,21 @@
{% for content in featured %}
<div class="large-8 medium-8 columns special-column">
{% if content.image %}
<img src="{{ content.image_url }}">
{% endif %}
<div class="index-text">
<h4><a href="{{ content.get_absolute_url }}" class="big-title">{{content.title}} </a></h4>
{% if content.datestart %}
<h6 class="big-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} </b></font>
{% if content.place %}<br/>{{content.place}}{% endif%}
</h6>
{% endif %}
{% if content.header %}
<p> {{content.formatted_header}} </p>
{% else %}
<p> {{content.formatted_body}} </p>
{% endif %}
<a href="{{ content.get_absolute_url }}">read more</a> </p>
</div>
</div>
{% endfor %}

View File

@ -7,46 +7,25 @@
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<div class="index-text"> <div class="index-text">
<h4 class="big-title">{{content.title}} </a></h4> <h4 class="big-title">{{content.title}} </a></h4>
<p> {{content.header}} </p> <p> {{content.formatted_header}} </p>
<p> {{content.body}} </p> <p> {{content.formatted_body}} </p>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="large-4 medium-4 columns"> <div class="large-4 medium-4 columns">
{% if upcoming_events.exists %}
<h4 class="sidebar-h4"> Upcoming Events </h4> <h4 class="sidebar-h4"> Upcoming Events </h4>
<div class="row"> {% include "event_preview.html" with events=upcoming_events %}
{% endif %}
{% for content in latest_content_list %} {% if ongoing_events.exists %}
{% if content.type_id == 1 %} <h4 class="sidebar-h4"> Ongoing Events </h4>
{% include "event_preview.html" with events=ongoing_events %}
<div class="row right-items"> {% endif %}
<div class= "small-12 columns"> {% if past_events.exists %}
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{content.datestart}} </b> <h4 class="sidebar-h4"> Past Events </h4>
{{ content.title }} <br /> {% include "event_preview.html" with events=past_events %}
{{ content.formatted_header|safe }} </font> {% endif %}
</h6> </div>
</div>
</div>
{% endif %}
{% if content.type_id == 0 %}
<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.type}}/{{ content.shortname }}/" class="sidebar-title">{{ content.title }}</a>
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b></font> <br/>
{{content.place}} </h6>
<p> {{content.header|striptags|truncatechars:100}} </p>
</div>
</div>
{% endif %}
{% endfor %}
</div> {% endblock %}
</div>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}
<div class="large-8 medium-8 columns special-column">
<div class="index-text">
<h4>{{content.title}}</h4>
{% if content.header %}
<p>
{{content.formatted_header|safe}}
</p>
{% endif %}
<p>
{{content.formatted_body|safe}}
</p>
</div>
</div>
{% endblock %}

View File

@ -2,36 +2,24 @@
{% block content %} {% block content %}
{% include "featured.html" %}
{% for content in content %} <div class="large-4 medium-4 columns">
{% if forloop.first %}
<div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{content.image}}">
<div class="index-text">
<h4><a href="/{{content.type}}/{{ content.shortname }}/" class="big-title">{{content.title}} </a></h4>
<p> {{content.header|striptags}} </p>
</div>
{% endif %}
{% endfor %}
</div>
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4">Projects </h4> <h4 class="sidebar-h4">Projects </h4>
<div class="row"> <div class="row">
{% for content in content %} {% for content in content %}
<div class="row right-items"> <div class="row right-items">
{% if content.image_url %}
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ content.image }}"> <img src="{{ content.image_url }}">
</div> </div>
{% endif %}
<div class="small-6 columns"> <div class="small-6 columns">
<a href="/{{content.type}}/{{ content.shortname }}/" class="sidebar-title">{{ content.title }}</a> <a href="{{content.get_absolute_url }}/" class="sidebar-title">{{ content.title }}</a>
<p> {{content.header|striptags|truncatechars:100}} </p> <p> {{content.header|striptags|truncatechars:100}} </p>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -5,9 +5,11 @@
{% block content %} {% block content %}
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{projects.image}}"> {% if projects.image %}
<img src="{{ projects.image_url }}">
{% endif %}
<div class="index-text"> <div class="index-text">
<h4><a href="/{{projects.type}}/{{ projects.shortname }}/" class="big-title">{{projects.title}} </a></h4> <h4><a href="{{ projects.get_absolute_url }}/" class="big-title">{{projects.title}} </a></h4>
<p> {{projects.formatted_header|safe}} </p> <p> {{projects.formatted_header|safe}} </p>
<p> {{projects.formatted_body|safe}} </p> <p> {{projects.formatted_body|safe}} </p>
</div> </div>
@ -21,10 +23,10 @@
{% for child in projects.children.all %} {% for child in projects.children.all %}
<div class="row related-row"> <div class="row related-row">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}"> <img src="{{ child.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<h6><a href="http://127.0.0.1:8000/{{child.type}}/{{child.shortname}}" class="sidebar-title"> {{child}} </a> </h6> <h6><a href="{{ child.get_absolute_url }}" class="sidebar-title"> {{child}} </a> </h6>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@ -35,11 +37,11 @@
{% for projects in latest_content_list %} {% for projects in latest_content_list %}
<div class="row right-items"> <div class="row right-items">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ projects.image }}"> <img src="{{ projects.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<a href="/{{projects.type}}/{{ projects.shortname }}/" class="sidebar-title">{{ projects.title }}</a> <a href="{{ projects.get_absolute_url }}/" class="sidebar-title">{{ projects.title }}</a>
<p> {{projects.header|striptags|truncatechars:100}} </p> <p> {{projects.formatted_teaser}} </p>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@ -49,4 +51,4 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,39 @@
{% extends 'base.html' %}
{% block content %}
<div class="row">
{% for content in results %}
{% if content.type.name == 'news' %}
<div class="row">
<div class= "small-12 columns">
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{content.datestart}} </b>
{{ content.title }} <br />
{{ content.formatted_header|striptags|safe }} </font>
</h6>
</div>
</div>
{% elif content.type.name == 'events' %}
<div class="row">
<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"> <font color="#ef4e5c"> <b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b></font> <br/>
{{content.place}} </h6>
<p> {{content.header|striptags|truncatechars:100|safe}} </p>
<a href="{{ content.get_absolute_url }}">read more</a> </p>
</div>
</div>
{% else %}
<div>
Add view for content type: {{content.type}}
</div>
{% endif %}
{% endfor %}
<br>
<br>
</div>
{% endblock %}

View File

@ -0,0 +1,25 @@
{% extends 'base.html' %}
{% block content %}
{% include "featured.html" %}
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4"> {{ section }} </h4>
<div class="row">
{% for content in content %}
<div class="row right-items">
{% if content.image_url %}
<div class="small-6 columns">
<img src="{{ content.image_url }}">
</div>
{% endif %}
<div class="small-6 columns">
<a href="{{ content.get_absolute_url }}/" class="sidebar-title">{{ content.title }}</a>
<p> {{content.header|striptags|truncatechars:100}} </p>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@ -6,9 +6,11 @@
{% for content in content %} {% for content in content %}
{% if forloop.first %} {% if forloop.first %}
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{content.image}}"> {% if content.image %}
<img src="{{content.image_url }}">
{% endif %}
<div class="index-text"> <div class="index-text">
<h4><a href="/{{content.type}}/{{ content.shortname }}/" class="big-title">{{content.title}} </a></h4> <h4><a href="{{ content.get_absolute_url }}/" class="big-title">{{content.title}} </a></h4>
<p> {{content.header|striptags}} </p> <p> {{content.header|striptags}} </p>
<p> {{content.body|striptags}} </p> <p> {{content.body|striptags}} </p>
</div> </div>
@ -23,11 +25,11 @@
{% for content in content %} {% for content in content %}
<div class="row right-items"> <div class="row right-items">
<a href="/{{content.type}}/{{ content.shortname }}/" class="sidebar-title">{{ content.title }}</a> <a href="{{ content.get_absolute_url }}" class="sidebar-title">{{ content.title }}</a>
<p> {{content.header|striptags|truncatechars:100}} </p> <p> {{content.header|striptags|truncatechars:100}} </p>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,13 +1,13 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% block content %}
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{texts.image}}"> {% if texts.image %}
<img src="{{ texts.image_url }}">
{% endif %}
<div class="index-text"> <div class="index-text">
<h4><a href="/{{texts.type}}/{{ texts.shortname }}/" class="big-title">{{texts.title}} </a></h4> <h4><a href="{{ texts.get_absolute_url }}/" class="big-title">{{texts.title}} </a></h4>
<p> {{texts.formatted_header|safe}} </p> <p> {{texts.formatted_header|safe}} </p>
<p> {{texts.formatted_body|safe}} </p> <p> {{texts.formatted_body|safe}} </p>
</div> </div>
@ -20,11 +20,13 @@
<h4 class="sidebar-h4"> Related </h4> <h4 class="sidebar-h4"> Related </h4>
{% for child in texts.children.all %} {% for child in texts.children.all %}
<div class="row related-row"> <div class="row related-row">
{% if child.image %}
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}"> <img src="{{ child.image_url }}">
</div> </div>
{% endif %}
<div class="small-6 columns"> <div class="small-6 columns">
<h6><a href="http://127.0.0.1:8000/{{child.type}}/{{child.shortname}}" class="sidebar-title"> {{child}} </a> </h6> <h6><a href="{{ child.get_absolute_url }}" class="sidebar-title"> {{child}} </a> </h6>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@ -34,11 +36,13 @@
{% for texts in latest_content_list %} {% for texts in latest_content_list %}
<div class="row right-items"> <div class="row right-items">
{% texts.image %}
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ texts.image }}"> <img src="{{ texts.image_url }}">
</div> </div>
{% endif %}
<div class="small-6 columns"> <div class="small-6 columns">
<a href="/{{texts.type}}/{{ texts.shortname }}/" class="sidebar-title">{{ texts.title }}</a> <a href="{{ texts.get_absolute_url }}" class="sidebar-title">{{ texts.title }}</a>
<p> {{texts.header|striptags|truncatechars:100}} </p> <p> {{texts.header|striptags|truncatechars:100}} </p>
</div> </div>
</div> </div>
@ -49,4 +53,4 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -2,36 +2,23 @@
{% block content %} {% block content %}
{% include "featured.html" %}
{% for content in content %} <div class="large-4 medium-4 columns">
{% if forloop.first %}
<div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{content.image}}">
<div class="index-text">
<h4><a href="/{{content.type}}/{{ content.shortname }}/" class="big-title">{{content.title}} </a></h4>
<p> {{content.header|striptags}} </p>
</div>
{% endif %}
{% endfor %}
</div>
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4"> Works </h4> <h4 class="sidebar-h4"> Works </h4>
<div class="row"> <div class="row">
{% for content in content %} {% for content in content %}
<div class="row right-items"> <div class="row right-items">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ content.image }}"> <img src="{{ content.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<a href="/{{content.type}}/{{ content.shortname }}/" class="sidebar-title">{{ content.title }}</a> <a href="{{ content.get_absolute_url }}/" class="sidebar-title">{{ content.title }}</a>
<p> {{content.header|striptags|truncatechars:100}} </p> <p> {{content.header|striptags|truncatechars:100}} </p>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -5,9 +5,9 @@
{% block content %} {% block content %}
<div class="large-8 medium-8 columns special-column"> <div class="large-8 medium-8 columns special-column">
<img src="http://camputer.org/images/{{works.image}}"> <img src="{{ works.image_url }}">
<div class="index-text"> <div class="index-text">
<h4><a href="/{{works.type}}/{{ works.shortname }}/" class="big-title">{{works.title}} </a></h4> <h4><a href="{{ works.get_absolute_url }}" class="big-title">{{works.title}} </a></h4>
<p> {{works.formatted_header|safe}} </p> <p> {{works.formatted_header|safe}} </p>
<p> {{works.formatted_body|safe}} </p> <p> {{works.formatted_body|safe}} </p>
</div> </div>
@ -21,10 +21,10 @@
{% for child in works.children.all %} {% for child in works.children.all %}
<div class="row related-row"> <div class="row related-row">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}"> <img src="{{ child.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<h6><a href="http://127.0.0.1:8000/{{child.type}}/{{child.shortname}}" class="sidebar-title"> {{child}} </a> </h6> <h6><a href="{{ child.get_absolute_url }}" class="sidebar-title"> {{child}} </a> </h6>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@ -35,10 +35,10 @@
{% for works in latest_content_list %} {% for works in latest_content_list %}
<div class="row right-items"> <div class="row right-items">
<div class="small-6 columns"> <div class="small-6 columns">
<img src="http://camputer.org/images/{{ works.image }}"> <img src="{{ works.image_url }}">
</div> </div>
<div class="small-6 columns"> <div class="small-6 columns">
<a href="/{{works.type}}/{{ works.shortname }}/" class="sidebar-title">{{ works.title }}</a> <a href="{{ works.get_absolute_url }}" class="sidebar-title">{{ works.title }}</a>
<p> {{works.header|striptags|truncatechars:100}} </p> <p> {{works.header|striptags|truncatechars:100}} </p>
</div> </div>
</div> </div>
@ -49,4 +49,4 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,64 +1,128 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.http import HttpResponse from datetime import datetime
from django.shortcuts import get_object_or_404, render
from .models import Content, ContentContent from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q from django.db.models import Q
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse
from django.views.generic.list import ListView from django.views.generic.list import ListView
from photologue.views import GalleryListView from photologue.views import GalleryListView
from photologue.models import Photo, Gallery from photologue.models import Photo, Gallery
from django.core.exceptions import ObjectDoesNotExist
from .models import Content, ContentContent
# Create your views here. # Create your views here.
def index(request): def index(request):
latest_content_list = Content.objects.order_by('-datestart')[:12] now = datetime.now()
homepage = Content.objects.filter(type=2).order_by('-datestart')[:1] display_events = ['news', 'events']
context = {'latest_content_list': latest_content_list, 'homepage': homepage} upcoming_events = Content.objects.filter(datestart__gt=now).filter(type__name__in=display_events).order_by('-datestart')[:12]
ongoing_events = Content.objects.filter(datestart__lt=now, dateend__gte=now).filter(type__name__in=display_events).order_by('-datestart')[:12]
past_events = Content.objects.filter(dateend__lt=now).filter(type__name__in=display_events).order_by('-datestart')[:12]
homepage = Content.objects.filter(type__name='homepage').order_by('-datestart')[:1]
context = {
'upcoming_events': upcoming_events,
'ongoing_events': ongoing_events,
'past_events': past_events,
'homepage': homepage}
return render(request, 'index.html', context) return render(request, 'index.html', context)
def project(request): def project(request):
content = Content.objects.filter(type=3).order_by('-datestart') type = 'projects'
return render(request, 'project.html', {'content': content}) featured = Content.objects.filter(type__name=type, featured=True).order_by('-datestart')[:1]
content = Content.objects.filter(type__name=type).order_by('-datestart')
return render(request, 'section_index.html', {
'section': 'Projects',
'featured': featured,
'content': content
})
def work(request): def work(request):
content = Content.objects.filter(type=4) type = 'works'
return render(request, 'text.html', {'content': content}) featured = Content.objects.filter(type__name=type, featured=True).order_by('-datestart')[:1]
content = Content.objects.filter(type__name=type).order_by('-datestart')
return render(request, 'section_index.html', {
'section': 'Works',
'featured': featured,
'content': content
})
def event(request): def event(request):
latest_content_list = Content.objects.filter(Q(type=0) | Q(type=1)).order_by('-datestart')[:8] now = datetime.now()
featured = Content.objects.filter(type=0).order_by('-datestart')[:1] display_events = ['events']
context = {'latest_content_list': latest_content_list, 'featured': featured} upcoming_events = Content.objects.filter(datestart__gt=now).filter(type__name__in=display_events).order_by('-datestart')
ongoing_events = Content.objects.filter(datestart__lt=now, dateend__gte=now).filter(type__name__in=display_events).order_by('-datestart')
past_events = Content.objects.filter(Q(dateend__lt=now)|Q(dateend=None, datestart__lt=now)).filter(type__name__in=display_events).order_by('-datestart')
featured = Content.objects.filter(type__name='events', featured=True).order_by('-datestart')[:1]
context = {
'upcoming_events': upcoming_events,
'ongoing_events': ongoing_events,
'past_events': past_events,
'featured': featured,
}
return render(request, 'event.html', context) return render(request, 'event.html', context)
def text(request): def text(request):
content = Content.objects.filter(type=5) type = 'texts'
return render(request, 'text.html', {'content': content}) featured = Content.objects.filter(type__name=type, featured=True).order_by('-datestart')[:1]
content = Content.objects.filter(type__name=type).order_by('-datestart')
return render(request, 'section_index.html', {
'section': 'Texts',
'featured': featured,
'content': content
})
def events(request, shortname): def events(request, shortname):
events = get_object_or_404(Content, shortname=shortname) if not shortname:
return event(request)
events = get_object_or_404(Content, shortname=shortname, type__name__in=['news', 'events'])
gallery = get_or_none(Gallery, slug=shortname) gallery = get_or_none(Gallery, slug=shortname)
latest_content_list = Content.objects.filter(type=0).order_by('-datestart') latest_content_list = Content.objects.filter(type__name='events').order_by('-datestart')
return render(request, 'events.html', {'events': events, 'latest_content_list': latest_content_list, 'gallery': gallery}) return render(request, 'events.html', {'events': events, 'latest_content_list': latest_content_list, 'gallery': gallery})
def projects(request, shortname): def projects(request, shortname):
projects = get_object_or_404(Content, shortname=shortname) if not shortname:
return project(request)
projects = get_object_or_404(Content, shortname=shortname, type__name='projects')
gallery = get_or_none(Gallery, slug=shortname) gallery = get_or_none(Gallery, slug=shortname)
latest_content_list = Content.objects.filter(type=3) latest_content_list = Content.objects.filter(type__name='projects')
return render(request, 'projects.html', {'projects': projects, 'latest_content_list': latest_content_list, 'gallery':gallery}) return render(request, 'projects.html', {'projects': projects, 'latest_content_list': latest_content_list, 'gallery':gallery})
def works(request, shortname): def works(request, shortname):
works = get_object_or_404(Content, shortname=shortname) if not shortname:
return work(request)
works = get_object_or_404(Content, shortname=shortname, type__name='works')
gallery = get_or_none(Gallery, slug=shortname) gallery = get_or_none(Gallery, slug=shortname)
latest_content_list = Content.objects.filter(type=4) latest_content_list = Content.objects.filter(type__name='works')
return render(request, 'works.html', {'works': works, 'latest_content_list': latest_content_list, 'gallery':gallery}) return render(request, 'works.html', {'works': works, 'latest_content_list': latest_content_list, 'gallery':gallery})
def texts(request, shortname): def texts(request, shortname):
if not shortname:
return text(request)
texts = get_object_or_404(Content, shortname=shortname) texts = get_object_or_404(Content, shortname=shortname)
gallery = get_or_none(Gallery, slug=shortname) gallery = get_or_none(Gallery, slug=shortname)
latest_content_list = Content.objects.filter(type=5) latest_content_list = Content.objects.filter(type__name='texts')
return render(request, 'texts.html', {'texts': texts, 'latest_content_list': latest_content_list, 'gallery':gallery}) return render(request, 'texts.html', {
'texts': texts,
'latest_content_list': latest_content_list,
'gallery':gallery
})
def page(request, shortname):
content = get_object_or_404(Content, shortname=shortname, type__name='page')
return render(request, 'page.html', {'content': content})
def search(request):
q = request.GET.get('q')
results = Content.objects.filter(body__contains=q).order_by('-datestart')
return render(request, 'results.html', {'results': results})
class GalleryListViews(ListView): class GalleryListViews(ListView):
@ -73,4 +137,25 @@ def get_or_none(classmodel, **kwargs):
return None return None
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'))
def redirect_images(request, image):
return redirect(image)