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

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc
local_settings.py
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
# 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!
DEBUG = True
@ -138,13 +135,35 @@ STATIC_ROOT = ''
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
MEDIA_URL = '/static/images/'
MEDIA_ROOT = '/Users/vaishk/camp/camp/static/images/'
MEDIA_URL = '/images/'
MEDIA_ROOT = os.path.join(BASE_ROOT, 'data/images')
IMAGE_PREFIX = 'http://studio.camp/images/'
try:
from local_settings import *
except:
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
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.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 content import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
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'^projects/(?P<shortname>\w+)/$', views.projects, name='projects'),
url(r'^works/(?P<shortname>\w+)/$', views.works, name='works'),
url(r'^texts/(?P<shortname>\w+)/$', views.texts, name='texts'),
url(r'^work/', views.work),
url(r'^project/', views.project),
url(r'^event/', views.event),
url(r'^text/', views.text),
url(r'^works/$', views.work),
url(r'^projects/$', views.project),
url(r'^events/$', views.event),
url(r'^texts/$', views.text),
url(r'^search/$', views.search),
url(r'^markdownx/', include(markdownx)),
url(r'^photologue/', include('photologue.urls', namespace='photologue')),
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):
model = ContentContent
fk_name = 'contentid2'
raw_id_fields = ['contentid1']
class ImagesInline(admin.StackedInline):
model = Image
@ -48,9 +49,9 @@ class GalleryAdmin(GalleryAdminDefault):
class ContentAdmin(admin.ModelAdmin):
save_on_top = True
list_display = ('__unicode__', 'datestart', 'type')
list_display = ('__unicode__', 'datestart', 'shortname', 'type')
list_filter = ['datestart', 'type']
search_fields = ['title', 'body', 'header']
search_fields = ['title', 'body', 'header', 'shortname']
inlines = [ContentParentsInline, ImagesInline, FileInline, LinkInline]
formfield_overrides = {
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 -*-
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.utils.html import mark_safe
from markdownx.models import MarkdownxField
from markdownx.utils import markdownify
import ox
# Create your models here.
@ -55,10 +61,11 @@ class Comments(models.Model): #not used
class Content(models.Model):
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)
header = MarkdownxField()
body = MarkdownxField()
header = MarkdownxField(blank=True, null=True, default='')
body = MarkdownxField(blank=True, null=True, default='')
teaser = models.TextField(blank=True, null=True, validators=[MaxLengthValidator(200)])
schedule = models.TextField(blank=True, null=True)
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.
@ -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.
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.
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase.
datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True) # Field name made lowercase.
published = models.IntegerField()
view = models.ForeignKey("Views", null=True, blank=True, db_column="view")
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, auto_now=True) # Field name made lowercase.
published = models.BooleanField(default=False)
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)
parentid = models.IntegerField(null=True, db_column='parentID', blank=True) # Field name made lowercase.
parents = models.ManyToManyField('Content', through='ContentContent', related_name= "children")
@ -83,16 +91,40 @@ class Content(models.Model):
@property
def formatted_header(self):
return markdownify(self.header)
return mark_safe(markdownify(self.header))
@property
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
def typefilter(self):
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:
managed = True

View File

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

View File

@ -2,51 +2,20 @@
{% extends 'base.html' %}
{% block content %}
{% 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>
{% include "featured.html" %}
<div class="large-4 medium-4 columns">
{% if upcoming_events.exists %}
<h4 class="sidebar-h4"> Upcoming Events </h4>
<div class="row">
{% for content in latest_content_list %}
{% if content.type_id == 1 %}
<div class="row right-items">
<div class= "small-12 columns">
<h6> {{ content.title }} <br />
{{ content.formatted_header|safe }}
</h6>
</div>
</div>
{% include "event_preview.html" with events=upcoming_events %}
{% 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 }} </b></font> <br/>
We will add a place to fill this text </h6>
</div>
</div>
{% if ongoing_events.exists %}
<h4 class="sidebar-h4"> Ongoing Events </h4>
{% include "event_preview.html" with events=ongoing_events %}
{% endif %}
{% if past_events.exists %}
<h4 class="sidebar-h4"> Past Events </h4>
{% include "event_preview.html" with events=past_events %}
{% 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 %}
<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">
<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_body|safe}} </p>
{% if gallery %}
@ -29,12 +31,16 @@
{% for child in events.children.all %}
<div class="row related-row">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}">
<img src="{{ child.image_url }}">
</div>
<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 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ child.datestart }} {% if child.dateend %} - {{child.dateend}} {% endif %} </b></font> <br/>
{{child.place}} </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>
{% if content.place %}<br/>{{content.place}}{% endif%}
</h6>
</div>
</div>
@ -47,12 +53,12 @@
<div class="row right-items">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ events.image }}">
<img src="{{ events.image_url }}">
</div>
<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>
<p> {{events.header|striptags|truncatechars:200}} </p>
<p> {{events.header|striptags|truncatechars:200|safe}} </p>
</div>
</div>

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="index-text">
<h4 class="big-title">{{content.title}} </a></h4>
<p> {{content.header}} </p>
<p> {{content.body}} </p>
<p> {{content.formatted_header}} </p>
<p> {{content.formatted_body}} </p>
</div>
{% endfor %}
</div>
<div class="large-4 medium-4 columns">
{% if upcoming_events.exists %}
<h4 class="sidebar-h4"> Upcoming Events </h4>
<div class="row">
{% for content in latest_content_list %}
{% if content.type_id == 1 %}
<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|safe }} </font>
</h6>
</div>
</div>
{% include "event_preview.html" with events=upcoming_events %}
{% 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>
{% if ongoing_events.exists %}
<h4 class="sidebar-h4"> Ongoing Events </h4>
{% include "event_preview.html" with events=ongoing_events %}
{% endif %}
{% if past_events.exists %}
<h4 class="sidebar-h4"> Past Events </h4>
{% include "event_preview.html" with events=past_events %}
{% endif %}
{% endfor %}
</div>
</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,31 +2,19 @@
{% block content %}
{% for content in content %}
{% 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>
{% include "featured.html" %}
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4">Projects </h4>
<div class="row">
{% for content in content %}
<div class="row right-items">
{% if content.image_url %}
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ content.image }}">
<img src="{{ content.image_url }}">
</div>
{% endif %}
<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>
</div>
</div>

View File

@ -5,9 +5,11 @@
{% block content %}
<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">
<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_body|safe}} </p>
</div>
@ -21,10 +23,10 @@
{% for child in projects.children.all %}
<div class="row related-row">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}">
<img src="{{ child.image_url }}">
</div>
<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>
{% endfor %}
@ -35,11 +37,11 @@
{% for projects in latest_content_list %}
<div class="row right-items">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ projects.image }}">
<img src="{{ projects.image_url }}">
</div>
<div class="small-6 columns">
<a href="/{{projects.type}}/{{ projects.shortname }}/" class="sidebar-title">{{ projects.title }}</a>
<p> {{projects.header|striptags|truncatechars:100}} </p>
<a href="{{ projects.get_absolute_url }}/" class="sidebar-title">{{ projects.title }}</a>
<p> {{projects.formatted_teaser}} </p>
</div>
</div>
{% endfor %}

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 %}
{% if forloop.first %}
<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">
<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.body|striptags}} </p>
</div>
@ -23,7 +25,7 @@
{% for content in content %}
<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>
</div>
{% endfor %}

View File

@ -1,13 +1,13 @@
{% extends 'base.html' %}
{% block content %}
<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">
<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_body|safe}} </p>
</div>
@ -20,11 +20,13 @@
<h4 class="sidebar-h4"> Related </h4>
{% for child in texts.children.all %}
<div class="row related-row">
{% if child.image %}
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}">
<img src="{{ child.image_url }}">
</div>
{% endif %}
<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>
{% endfor %}
@ -34,11 +36,13 @@
{% for texts in latest_content_list %}
<div class="row right-items">
{% texts.image %}
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ texts.image }}">
<img src="{{ texts.image_url }}">
</div>
{% endif %}
<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>
</div>
</div>

View File

@ -2,31 +2,18 @@
{% block content %}
{% for content in content %}
{% 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>
{% include "featured.html" %}
<div class="large-4 medium-4 columns">
<h4 class="sidebar-h4"> Works </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 }}">
<img src="{{ content.image_url }}">
</div>
<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>
</div>
</div>

View File

@ -5,9 +5,9 @@
{% block content %}
<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">
<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_body|safe}} </p>
</div>
@ -21,10 +21,10 @@
{% for child in works.children.all %}
<div class="row related-row">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ child.image }}">
<img src="{{ child.image_url }}">
</div>
<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>
{% endfor %}
@ -35,10 +35,10 @@
{% for works in latest_content_list %}
<div class="row right-items">
<div class="small-6 columns">
<img src="http://camputer.org/images/{{ works.image }}">
<img src="{{ works.image_url }}">
</div>
<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>
</div>
</div>

View File

@ -1,64 +1,128 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from .models import Content, ContentContent
from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
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 photologue.views import GalleryListView
from photologue.models import Photo, Gallery
from django.core.exceptions import ObjectDoesNotExist
from .models import Content, ContentContent
# Create your views here.
def index(request):
latest_content_list = Content.objects.order_by('-datestart')[:12]
homepage = Content.objects.filter(type=2).order_by('-datestart')[:1]
context = {'latest_content_list': latest_content_list, 'homepage': homepage}
now = datetime.now()
display_events = ['news', 'events']
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)
def project(request):
content = Content.objects.filter(type=3).order_by('-datestart')
return render(request, 'project.html', {'content': content})
type = 'projects'
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):
content = Content.objects.filter(type=4)
return render(request, 'text.html', {'content': content})
type = 'works'
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):
latest_content_list = Content.objects.filter(Q(type=0) | Q(type=1)).order_by('-datestart')[:8]
featured = Content.objects.filter(type=0).order_by('-datestart')[:1]
context = {'latest_content_list': latest_content_list, 'featured': featured}
now = datetime.now()
display_events = ['events']
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)
def text(request):
content = Content.objects.filter(type=5)
return render(request, 'text.html', {'content': content})
type = 'texts'
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):
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)
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})
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)
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})
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)
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})
def texts(request, shortname):
if not shortname:
return text(request)
texts = get_object_or_404(Content, shortname=shortname)
gallery = get_or_none(Gallery, slug=shortname)
latest_content_list = Content.objects.filter(type=5)
return render(request, 'texts.html', {'texts': texts, 'latest_content_list': latest_content_list, 'gallery':gallery})
latest_content_list = Content.objects.filter(type__name='texts')
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):
@ -73,4 +137,25 @@ def get_or_none(classmodel, **kwargs):
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)