relations, fix texts, show opt pages

This commit is contained in:
root 2017-12-18 13:44:11 +00:00 committed by j
parent fb828607f9
commit 905b41e666
7 changed files with 38 additions and 10 deletions

View File

@ -36,10 +36,10 @@ urlpatterns = [
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'^texts/(?P<shortname>.+)/$', views.texts, name='texts'),
url(r'^events/(?P<shortname>.+)/$', views.events, name='events'),
url(r'^projects/(?P<shortname>.+)/$', views.projects, name='projects'),
url(r'^works/(?P<shortname>.+)/$', views.works, name='works'),
url(r'^works/$', views.work),
url(r'^projects/$', views.project),
url(r'^events/$', views.event),

View File

@ -83,7 +83,7 @@ class Content(models.Model):
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.
parentid = models.IntegerField(null=True, db_column='parentID', blank=True, editable=False) # delete
parents = models.ManyToManyField('Content', through='ContentContent', related_name= "children")
def __unicode__(self):
@ -142,6 +142,13 @@ class ContentContent(models.Model):
# managed = False
db_table = 'content_content'
def reverse(self):
r, created = ContentContent.objects.get_or_create(contentid1=self.contentid2, contentid2=self.contentid1)
return r
def save(self, *args, **kwargs):
super(ContentContent, self).save(*args, **kwargs)
self.reverse()
class ContentKeyword(models.Model):
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.

View File

@ -12,6 +12,7 @@
<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>
{% include "opt.html" with content=events %}
{% if gallery %}
<h6><strong>Gallery: {{gallery.title}}</strong></h6>
<ul class="clearing-thumbs" data-clearing>

View File

@ -0,0 +1,18 @@
{% 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 %}

View File

@ -12,6 +12,7 @@
<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>
{% include "opt.html" with content=projects %}
</div>
</div>

View File

@ -10,6 +10,7 @@
<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>
{% include "opt.html" with content=texts %}
</div>
</div>
@ -36,7 +37,7 @@
{% for texts in latest_content_list %}
<div class="row right-items">
{% texts.image %}
{% if texts.image %}
<div class="small-6 columns">
<a href="{{ texts.get_absolute_url }}"> <img src="{{ texts.image_url }}"></a>
</div>

View File

@ -55,7 +55,7 @@ def event(request):
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')
past_events = Content.objects.filter(Q(dateend__lt=now)|Q(dateend=None, datestart__lt=now)).filter(type__name__in=display_events).order_by('-datestart')[:10]
featured = Content.objects.filter(type__name='events', featured=True).order_by('-datestart')[:1]
context = {
@ -82,7 +82,7 @@ def events(request, 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__name='events').order_by('-datestart')
latest_content_list = Content.objects.filter(type__name='events').order_by('-datestart')[:10]
return render(request, 'events.html', {'events': events, 'latest_content_list': latest_content_list, 'gallery': gallery})
def projects(request, shortname):
@ -90,7 +90,7 @@ def projects(request, 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__name='projects')
latest_content_list = Content.objects.filter(type__name='projects').order_by('-datestart')
return render(request, 'projects.html', {'projects': projects, 'latest_content_list': latest_content_list, 'gallery':gallery})
def works(request, shortname):
@ -104,7 +104,7 @@ def works(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, type__name='texts')
gallery = get_or_none(Gallery, slug=shortname)
latest_content_list = Content.objects.filter(type__name='texts')
return render(request, 'texts.html', {