Commit c6c00352 authored by gijs's avatar gijs
Browse files

Started to group trajectories

parent 6002fcbe
......@@ -74,14 +74,14 @@ class DateRange (object):
class Field (object):
def __init__ (self, default = []):
self.default = default
self.value = None
self._value = None
# no-op
def parse (self, value):
return value
def set (self, value):
self.value = [self.parse(v) for v in value]
self._value = [self.parse(v) for v in value]
def __repr__ (self):
return repr(self.value)
......@@ -91,6 +91,13 @@ class Field (object):
def __iter__ (self):
return iter(self.value)
@property
def value (self):
if self._value:
return self._value
else:
return self.default
# def __call__ (self, value):
# if value:
......
......@@ -78,8 +78,6 @@ def groupedProgrammeItems(event):
programmeItems = sorted(event.programmeItems.targets, key=datetimesorter)
return regroup(programmeItems, lambda e: datesorter(e).strftime(DATE_OUTPUT_FORMAT))
produser_role_sorting = ['artist', 'co-producer', 'other professional', 'team', 'partner']
def generate ():
# Clear existing collections
resetCollections(contentTypes)
......@@ -101,6 +99,7 @@ def generate ():
os.mkdir(os.path.join(outputdir, 'pages'))
os.mkdir(os.path.join(outputdir, 'tags'))
os.mkdir(os.path.join(outputdir, 'notes'))
os.mkdir(os.path.join(outputdir, 'questions'))
models = parse_pads()
......@@ -115,6 +114,7 @@ def generate ():
externalProjects = collectionFor('external-project')
notes = collectionFor('notes')
trajectories = collectionFor('trajectory')
questions = collectionFor('question')
def getProduserSortKey (produser):
attr = try_attributes(produser, ['sortname', 'name', 'produser'])
......@@ -124,6 +124,12 @@ def generate ():
else:
return None
def getTrajectorySortKey (trajectory):
if trajectory.produser.resolved:
return getProduserSortKey(trajectory.produser.target)
else:
return ''
def getLabelAsSortKey (model):
label = getattr(model, model.labelField)
......@@ -132,14 +138,70 @@ def generate ():
else:
return ''
grouped_produsers = sorted(regroup(sorted(produsers.models, key=getProduserSortKey), 'role'), key=lambda group: produser_role_sorting.index(group[0]) if group[0] in produser_role_sorting else inf)
def makeGroupSorter (order):
def sorter (line):
sortKey = line[0]
return order.index(sortKey) if sortKey in order else inf
return sorter
def makeAttributeSorter(attributes):
def sorter (model):
return str(try_attributes(model, attributes)).lower()
return sorter
## Produsers
## First
produser_role_sorting = ['artist', 'co-producer', 'other professional', 'team', 'partner']
sorted_produsers = sorted(produsers.models, key=getProduserSortKey)
grouped_produsers = sorted(regroup(sorted_produsers, 'role'), key=makeGroupSorter(produser_role_sorting))
output(os.path.join(outputdir, 'produsers.html'), 'produsers.html', { 'produsers': sorted(produsers.models, key=lambda r: str(try_attributes(r, ['sortname', 'name', 'produser', 'key'])).lower()), 'grouped_produsers': grouped_produsers })
output(
os.path.join(outputdir, 'produsers.html'),
'produsers.html',
{
'produsers': sorted(produsers.models, key=makeAttributeSorter(['sortname', 'name', 'produser', 'key'])),
'grouped_produsers': grouped_produsers })
# output(os.path.join(outputdir, 'produsers.layout.html'), 'produsers.layout.html', { 'produsers': sorted(produsers.models, key=lambda r: str(r.key)), 'grouped_produsers': grouped_produsers })
output(os.path.join(outputdir, 'tags.html'), 'tags.html', { 'tags': sorted(tags.models, key=getLabelAsSortKey) })
output(os.path.join(outputdir, 'bibliography.html'), 'bibliography.html', { 'bibliography': sorted(bibliography.models, key=getLabelAsSortKey) })
output(os.path.join(outputdir, 'external-projects.html'), 'external-projects.html', { 'externalProjects': sorted(externalProjects.models, key=getLabelAsSortKey) })
output(os.path.join(outputdir, 'trajectories.html'), 'trajectories.html', { 'trajectories': trajectories.models })
## Tags
output(
os.path.join(outputdir, 'tags.html'),
'tags.html',
{ 'tags': sorted(tags.models, key=getLabelAsSortKey) })
## Bibliography
output(
os.path.join(outputdir, 'bibliography.html'),
'bibliography.html',
{ 'bibliography': sorted(bibliography.models, key=getLabelAsSortKey) })
## External projects
output(
os.path.join(outputdir, 'external-projects.html'),
'external-projects.html',
{ 'externalProjects': sorted(externalProjects.models, key=getLabelAsSortKey) })
## Trajectories
trajectory_category_sorting = ['artisttrajectory', 'designertrajectory', 'reflection']
sorted_trajectories = sorted(trajectories.models, key=getTrajectorySortKey)
grouped_trajectories = sorted(regroup(sorted_trajectories, 'category'), key=makeGroupSorter(trajectory_category_sorting))
output(
os.path.join(outputdir, 'trajectories.html'),
'trajectories.html',
{
'trajectories': sorted_trajectories,
'grouped_trajectories': grouped_trajectories
})
## Questions
output(
os.path.join(outputdir, 'questions.html'),
'questions.html',
{ 'questions': questions.models }
)
# for produser in produsers.models:
# output(os.path.join(outputdir, produser.prefix, '{}.html'.format(produser.key)), 'produser.html', { 'produser': produser })
......@@ -152,8 +214,6 @@ def generate ():
generate_single_pages(pages.models, 'page.html', outputdir, lambda page: { 'page': page })
generate_single_pages(tags.models, 'tag.html', outputdir, lambda tag: { 'tag': tag })
generate_single_pages(filter(lambda e: not hasattr(e, 'programmeItems') or not e.programmeItems, events.models), 'event.html', outputdir, lambda event: { 'event': event })
generate_single_pages(filter(lambda e: hasattr(e, 'programmeItems') and e.programmeItems, events.models), 'event-with-programme-items.html', outputdir, lambda event: { 'event': event, 'groupedProgrammeItems': groupedProgrammeItems(event)})
generate_single_pages(notes.models, 'note.html', outputdir, lambda note: { 'note': note })
......
......@@ -143,6 +143,7 @@ class LinkField(object):
def resolve (self, source):
if self.value:
self.value.resolve(source)
self.resolved = True
# Should we also resolve the reverse link?
if not self.value.broken and self.reverse:
# If so provide a reversed version of the link
......@@ -288,17 +289,26 @@ class ReverseMultiLinkField(ReverseLinkField):
def targets (self):
return [link.target for link in self.value]
# Returns true id the given object is a LinkField
# or a MultiLinkField
def is_link (obj):
return isinstance(obj, (LinkField, MultiLinkField))
# Returns true if the given object is a LinkField
def is_single_link (obj):
return isinstance(obj, (LinkField,))
def is_multi_link (obj):
return isinstance(obj, (MultiLinkField))
return isinstance(obj, (MultiLinkField,))
def is_reverse_link (obj):
return isinstance(obj, (ReverseLinkField, ReverseMultiLinkField))
def is_reverse_single_link (obj):
return isinstance(obj, (ReverseLinkField,))
def is_reverse_multi_link (obj):
return isinstance(obj, (ReverseMultiLinkField))
return isinstance(obj, (ReverseMultiLinkField,))
def linkMultiReverse(contentType, reverseName):
return LinkField(contentType=contentType, reverse=ReverseMultiLinkField(reverseName))
......@@ -766,10 +776,12 @@ class ProgrammeItem (Model):
labelField = 'title'
def link (self):
if self.event.target:
if is_multi_link(self.event) or is_reverse_multi_link(self.event):
return self.event.targets[0].link + '#' + self.key
elif is_single_link(self.event) or is_reverse_single_link(self.event):
return self.event.target.link + '#' + self.key
else:
return ''
return '#broken'
def _metadataFields (self):
return {
......@@ -809,6 +821,7 @@ class Trajectory (Model):
def _metadataFields (self):
return {
'produser': linkMultiReverse('produser', 'trajectories'),
'category': fields.Single(fields.StringField(['artisttrajectory'])),
'tags': multiLinkMultiReverse('tag', 'trajectories')
}
......
{% extends "generator_base.html" %}
{% block title %}
Caveat
{% if note.programmeItem %}
{% if note.programmeItem.resolved %}
→ {{ note.programmeItem }}
{% elif note.event %}
{% elif note.event.resolved %}
→ {{ note.event }}
{% endif %}
→ {{ note.title|striptags }}
......@@ -11,11 +11,11 @@
{% block content %}
<nav class="breadcrumbs">
<ul>
{% if note.programmeItem %}
<li><a href="../activities.html">Activities</a></li>
{% if note.programmeItem.resolved %}
<li><a href="../index.html">Timeline</a></li>
<li><a href="{{ note.programmeItem.target.link }}">{{ note.programmeItem }}</a></li>
{% elif note.event %}
<li><a href="../activities.html">Activities</a></li>
{% elif note.event.resolved %}
<li><a href="../index.html">Timeline</a></li>
<li><a href="{{ note.event.target.link }}">{{ note.event }}</a></li>
{% endif %}
<li>{{ note }}</li>
......
......@@ -7,6 +7,38 @@
Caveat gathers these as 'trajectories', since they are process-based, durational,
and do not necessarily have a tangible outcome.
</p>
{% for category, trajectories in grouped_trajectories %}
{% if category == 'artisttrajectory' %}
<h3>Artists trajectories</h3>
<p>
<em>Caveat</em> attributes a central role to a large number of artists who are invited to do in-depth research through their art practices into the socio-economic and legal conditions of these practices.
</p>
{% elif category == 'designertractory' %}
<h3>Designer trajectories</h3>
<p>
As one of <em>Caveat</em>'s partners, open-source design collective OSP pursues a research into fair design practice: Ecotones of Collaboration.
</p>
{% elif category == 'reflection' %}
<h3>Reflections</h3>
<p>
Critial considerations by the <em>Caveat</em> research team and 'dramaturgs' , and by invited guest writers put the research trajectories in different perspectives from their art historical, legal, sociological and other backgrounds.
</p>
{% endif %}
<section class="trajectory-list">
{% for trajectory in trajectories %}
<section class="trajectory">
<h2 class="produser">
<a href="{{ trajectory.produser.target.link }}">{{ trajectory.produser }}</a>
</h2>
{% if trajectory.summary %}
{{ trajectory.summary }}
{% else %}
{{ trajectory.content }}
{% endif %}
</section>
{% endfor %}
</section>
{% endfor %}
<section class="trajectory-list">
{% for trajectory in trajectories %}
<section class="trajectory">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment