Skip to content
Browse files

Documentation

  • Loading branch information...
1 parent 5ec93b1 commit 034c31092761a5ecf93875976a779588dad712eb daniele committed
View
2 contacts_and_people/templates/contacts_and_people/persondetails.html
@@ -110,7 +110,7 @@
<h1>Displaying the entities a person belongs to</h1>
<p class="explanation">This needs some improvement - at the moment it will only display the first tree's root node.</p>
<ul>
- {% make_membership_tree entity.get_root %}
+ {% make_membership_tree person entity.get_root %}
</ul>
</body>
View
5 contacts_and_people/templates/entitytree.html
@@ -1,6 +1,5 @@
{% load contacts_and_people_tags %}
{% if node %}
-
{% if not node.abstract_entity %}
<li><a href="{{ node.get_absolute_url }}">
{% ifequal person.home_entity node %}
@@ -12,7 +11,7 @@
{% if node.get_children %}
<ul>
{% for item in node.get_children %}
- {% make_membership_tree item %}
+ {% make_membership_tree person item %}
{% endfor %}
</ul>
{% endif %}
@@ -20,7 +19,7 @@
{% else %}
{% if node.get_children %}
{% for item in node.get_children %}
- {% make_membership_tree item %}
+ {% make_membership_tree person item %}
{% endfor %}
{% endif %}
{% endif %}
View
13 contacts_and_people/templatetags/contacts_and_people_tags.py
@@ -7,10 +7,19 @@
register = template.Library()
@register.inclusion_tag('entitytree.html', takes_context=True)
-def make_membership_tree(context, node):
+def make_membership_tree(context, person, node):
+ """This function recurses, by using the template entitytree.html which in turn calls this function """
+ if node in person.gather_entities():
+ return {
+ 'node': node,
+ 'person': person,
+ }
+
+@register.inclusion_tag('entitytree.html', takes_context=True)
+def list_members_of_entity(context, node):
person=context['person']
if node in person.gather_entities():
return {
'node': node,
'person': person,
- }
+ }
View
50 docs/tags_etc.md
@@ -0,0 +1,50 @@
+Entity
+======
+Each office, department, committee, centre within an institution is an Entity.
+Entities are organised into a hierarchy, for example:
+The University
+ Faculties
+ Faculty of Humanities
+ Department of Philosophy
+ Philosophy Examination Board
+
+
+Entity.gather_members()
+
+For an entity, and all its descendants, produces a list of members (it returns a set).
+
+Entity.build_address()
+
+Assembles the institutional (as opposed to postal) part of an entity's address.
+
+The build_address function allows us to eliminate unnecessary or undesired lines from the ancestry for the purpose of constructing address. For example, "Cardiff University School of Medicine" does not need to show its parent ("Cardiff University") in its address - that would just look silly.
+
+Also, we leave out abstract entities (e.g. "Faculties").
+
+Person
+======
+
+Person.gather_entities()
+
+For a person, produces a list of entities that the person belongs to. It also includes all the descendants of these entities (if you belong to a child you belong to its parent).
+
+
+Templatetags
+============
+
+{% make_membership_tree person root %}
+
+For a person, will list all the entities they belong to, whether explicitly or implicitly, and make a tree to display them in.
+
+root is the starting point of the tree.
+
+The easiest way to get root is by using MPTT's get_root, as in:
+
+{% make_membership_tree entity.get_root %}
+
+See http://www.jonathanbuchanan.plus.com/mptt/models.html for more on get_root.
+
+make_membership_tree recurses - it uses the template entitytree.html, which in turn calls make_membership tree, until they run out of tree nodes to process.
+
+
+

0 comments on commit 034c310

Please sign in to comment.
Something went wrong with that request. Please try again.