display more content, only show published material

This commit is contained in:
j 2017-12-09 12:52:46 +01:00
parent 9e2e37b645
commit 9077723b1a
5 changed files with 89 additions and 345 deletions

View File

@ -18,8 +18,9 @@ class ServerAdmin(admin.ModelAdmin):
'''
class ResourcesAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'type', 'mime')
search_fields = ['href']
list_filter = ['mime']
list_filter = ['type', 'mime']
admin.site.register(models.Resources, ResourcesAdmin)
@ -32,7 +33,7 @@ class ResourcesInline(admin.StackedInline):
class ContentAdmin(admin.ModelAdmin):
save_on_top = True
list_display = ('__unicode__', 'datestart', 'type')
list_filter = ['datestart', 'type', 'view']
list_filter = ['datestart', 'type', 'view', 'published']
search_fields = ['title', 'body', 'header']
raw_id_fields = ['parent']

View File

@ -86,3 +86,12 @@ body, h1, h2, h3, h4, h5, h6 {
top: 45px;
right: 25px;
}
.context ul, .links ul {
list-style: none;
}
.images img {
max-width: 128px;
float: left;
}

View File

@ -14,34 +14,78 @@
<h4>{{ content.header|safe }} </h4>
<p>{{ content.body|safe }}</p>
{% if content.children.exists %}
<b>Child Nodes:</b> <br>
{% if content.optbtn2 and content.opttext2 %}
<div class="part2">
<h4>{{ content.optbtn2|safe }} </h4>
<p>{{ content.opttext2|safe|linebreaks }}</p>
</div>
{% endif %}
{% if content.optbtn3 and content.opttext3 %}
<div class="part3">
<h4>{{ content.optbtn3|safe }} </h4>
<p>{{ content.opttext3|safe|linebreaks }}</p>
</div>
{% endif %}
{% if content.schedule %}
<div class="schedule">
<h4>{{content.schedulebutton|default:"Schedule"}}</h4>
<p>{{ content.schedule|safe|linebreaks }}</p>
</div>
{% endif %}
<div class="context">
<b>In This Event</b>:
<ul>
{% if content.parent and content.parent.title %}
<li><a href="{{content.parent.get_absolute_url}}">{{content.parent.title}}</a></li>
<li><ul>
{% for node in content.parent.children.all %}
{% if node.shortname and node.published %}
<li>
{% if node == content %}
{{node.title}}
{% else %}
<a href="{{node.get_absolute_url}}">{{ node.title }}</a>
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul><li>
{% elif content.children.exists %}
<li>{{content.title}}</li>
<li><ul>
{% for node in content.children.all %}
{% if node.shortname %}
{% if node.shortname and node.published %}
<li>
<a href="{{node.get_absolute_url}}">{{ node.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul><li>
{% else %}
<li>{{content.title}}</li>
{% endif %}
</ul>
{% endif %}
{% if content.parent and content.parent.title %}
<b>Part of:</b><br>
<a href="{{content.parent.get_absolute_url}}">{{content.parent.title}}</a>
{% endif %}
</div>
{% if content.resources.exists %}
<style>
.resources img {
max-width: 128px;
float: left;
}
</style>
<div class="resources">
<b>Resources:</b> <br>
{% for res in content.resources.all %}
{% if content.links.exists %}
<div class="links">
<b>Links:</b>
<ul>
{% for res in content.links %}
<li>
<a href="{{res.get_absolute_url}}">{{res.description|default:res.href}}</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if content.images.exists %}
<div class="images">
<b>Images:</b> <br>
{% for res in content.images %}
<div>
{% if res.is_image %}
<img src="{{res.get_absolute_url}}">
@ -57,5 +101,6 @@
<br clear="all">
</div>
{% endif %}
{% endif %}
</div>
{% endblock %}

View File

@ -8,16 +8,19 @@ from .models import Content
def index(request):
latest_content_list = Content.objects.order_by('-datestart')[:5]
content = Content.objects.all()
content = content.filter(published=True)
latest_content_list = ocntent.order_by('-datestart')[:5]
context = {'latest_content_list': latest_content_list}
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, published=True)
return render(request, 'detail.html', {'content': content})
def projects(request):
content = Content.objects.filter(type__name='ongoing').exclude(shortname='').order_by('-datestart')
content = content.filter(published=True)
return render(request, 'projects.html', {
'content': content,
'title': 'Projects'
@ -26,6 +29,7 @@ def projects(request):
def events(request):
content = Content.objects.filter(type__name='events').exclude(shortname='')
content = Content.objects.filter(type__name='events').exclude(shortname='').order_by('-datestart')
content = content.filter(published=True)
return render(request, 'projects.html', {
'content': content,
'title': 'Upcoming Events'
@ -33,6 +37,7 @@ def events(request):
def works(request):
content = Content.objects.filter(type__name='works').exclude(shortname='').order_by('-datestart')
content = content.filter(published=True)
return render(request, 'projects.html', {
'content': content,
'title': 'Works'
@ -40,6 +45,7 @@ def works(request):
def texts(request):
content = Content.objects.filter(type__name='texts').exclude(shortname='')
content = content.filter(published=True)
return render(request, 'projects.html', {
'content': content,
'title': 'Texts'

View File

@ -1,317 +0,0 @@
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
class Acrolike(models.Model):
title = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'acrolike'
class Acronym(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
c = models.CharField(max_length=50, blank=True, null=True)
a = models.CharField(max_length=50, blank=True, null=True)
m = models.CharField(max_length=50, blank=True, null=True)
p = models.CharField(max_length=50, blank=True, null=True)
class Meta:
managed = False
db_table = 'acronym'
class Audios(models.Model):
filename = models.CharField(max_length=255)
title = models.CharField(max_length=255, blank=True, null=True)
description = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'audios'
class AuthGroup(models.Model):
name = models.CharField(unique=True, max_length=80)
class Meta:
managed = False
db_table = 'auth_group'
class AuthGroupPermissions(models.Model):
group_id = models.IntegerField()
permission_id = models.IntegerField()
class Meta:
managed = False
db_table = 'auth_group_permissions'
unique_together = (('group_id', 'permission_id'),)
class AuthPermission(models.Model):
name = models.CharField(max_length=50)
content_type_id = models.IntegerField()
codename = models.CharField(max_length=100)
class Meta:
managed = False
db_table = 'auth_permission'
unique_together = (('content_type_id', 'codename'),)
class AuthUser(models.Model):
username = models.CharField(unique=True, max_length=30)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.CharField(max_length=75)
password = models.CharField(max_length=128)
is_staff = models.IntegerField()
is_active = models.IntegerField()
is_superuser = models.IntegerField()
last_login = models.DateTimeField()
date_joined = models.DateTimeField()
class Meta:
managed = False
db_table = 'auth_user'
class AuthUserGroups(models.Model):
user_id = models.IntegerField()
group_id = models.IntegerField()
class Meta:
managed = False
db_table = 'auth_user_groups'
unique_together = (('user_id', 'group_id'),)
class AuthUserUserPermissions(models.Model):
user_id = models.IntegerField()
permission_id = models.IntegerField()
class Meta:
managed = False
db_table = 'auth_user_user_permissions'
unique_together = (('user_id', 'permission_id'),)
class Comments(models.Model):
comment = models.TextField()
name = models.CharField(max_length=150, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
personid = models.IntegerField(db_column='personID', 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.
parentid = models.IntegerField(db_column='parentID', blank=True, null=True) # Field name made lowercase.
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.
ip = models.CharField(db_column='IP', max_length=50, blank=True, null=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'comments'
class Content(models.Model):
shortname = models.CharField(db_column='shortName', max_length=255) # Field name made lowercase.
title = models.CharField(max_length=255)
header = models.TextField(blank=True, null=True)
body = models.TextField(blank=True, null=True)
place = 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.
optbtn2 = models.CharField(db_column='optBtn2', max_length=127, blank=True, null=True) # Field name made lowercase.
opttext2 = models.TextField(db_column='optText2', blank=True, null=True) # Field name made lowercase.
optbtn3 = models.CharField(db_column='optBtn3', max_length=127, blank=True, null=True) # Field name made lowercase.
opttext3 = models.TextField(db_column='optText3', blank=True, null=True) # Field name made lowercase.
technotes = models.TextField()
image = models.CharField(max_length=150, blank=True, null=True)
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.
type = models.IntegerField()
published = models.IntegerField()
view = models.IntegerField(blank=True, null=True)
parentid = models.IntegerField(db_column='parentId') # Field name made lowercase.
class Meta:
managed = True
db_table = 'content'
class ContentContent(models.Model):
contentid1 = models.IntegerField(db_column='contentID1') # Field name made lowercase.
contentid2 = models.IntegerField(db_column='contentID2') # Field name made lowercase.
class Meta:
managed = False
db_table = 'content_content'
class ContentKeyword(models.Model):
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.
keywordid = models.IntegerField(db_column='keywordID') # Field name made lowercase.
class Meta:
managed = False
db_table = 'content_keyword'
class ContentResource(models.Model):
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.
resourceid = models.IntegerField(db_column='resourceID') # Field name made lowercase.
class Meta:
managed = False
db_table = 'content_resource'
class ContentTypes(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'content_types'
class DjangoAdminLog(models.Model):
action_time = models.DateTimeField()
user_id = models.IntegerField()
content_type_id = models.IntegerField(blank=True, null=True)
object_id = models.TextField(blank=True, null=True)
object_repr = models.CharField(max_length=200)
action_flag = models.SmallIntegerField()
change_message = models.TextField()
class Meta:
managed = False
db_table = 'django_admin_log'
class DjangoContentType(models.Model):
name = models.CharField(max_length=100)
app_label = models.CharField(max_length=100)
model = models.CharField(max_length=100)
class Meta:
managed = False
db_table = 'django_content_type'
unique_together = (('app_label', 'model'),)
class DjangoSession(models.Model):
session_key = models.CharField(primary_key=True, max_length=40)
session_data = models.TextField()
expire_date = models.DateTimeField()
class Meta:
managed = False
db_table = 'django_session'
class DjangoSite(models.Model):
domain = models.CharField(max_length=100)
name = models.CharField(max_length=50)
class Meta:
managed = False
db_table = 'django_site'
class Keywords(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'keywords'
class People(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
location = models.CharField(max_length=255, blank=True, null=True)
login = models.CharField(max_length=100, blank=True, null=True)
password = models.CharField(max_length=16, blank=True, null=True)
href = models.CharField(max_length=255, blank=True, null=True)
bio = models.TextField(blank=True, null=True)
type = models.IntegerField()
class Meta:
managed = False
db_table = 'people'
class PersonContent(models.Model):
personid = models.IntegerField(db_column='personID') # Field name made lowercase.
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.
level = models.IntegerField()
class Meta:
managed = False
db_table = 'person_content'
class PersonResource(models.Model):
personid = models.IntegerField(db_column='personID') # Field name made lowercase.
resourceid = models.IntegerField(db_column='resourceID') # Field name made lowercase.
class Meta:
managed = False
db_table = 'person_resource'
class Resources(models.Model):
type = models.IntegerField()
href = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
mime = models.CharField(max_length=10, blank=True, null=True)
width = models.IntegerField(blank=True, null=True)
height = models.IntegerField(blank=True, null=True)
istech = models.IntegerField(db_column='isTech') # Field name made lowercase.
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase.
orderno = models.IntegerField(db_column='orderNo', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'resources'
class Videos(models.Model):
sha1 = models.CharField(max_length=50)
href = models.CharField(max_length=255)
title = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
width = models.IntegerField(blank=True, null=True)
height = models.IntegerField(blank=True, null=True)
duration = models.IntegerField(blank=True, null=True)
thumbno = models.IntegerField(db_column='thumbNo') # Field name made lowercase.
image = models.CharField(max_length=255, blank=True, null=True)
contentid = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'videos'
class Views(models.Model):
name = models.CharField(max_length=255)
href = models.CharField(max_length=255, blank=True, null=True)
class Meta:
managed = False
db_table = 'views'