Skip to content

Commit

Permalink
handle story updates in dashboard updates view (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianekaplan authored Oct 22, 2024
1 parent 24f7b6f commit e609daa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mysite/familytree/templates/familytree/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h2><a href="{% url 'outline' %}">Outline View</a></h2>
{% if not user_is_guest %}
<div class="circled_section">
<b>Latest updates:</b><br/>
{% for update, person, content_type, change_type, updated_person in recent_updates %}
{% for update, person, content_type, change_type, updated_person, updated_story in recent_updates %}
{% include "familytree/update_partial.html"%}
{% endfor %}
</div>
Expand Down
4 changes: 4 additions & 0 deletions mysite/familytree/templates/familytree/update_partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

{% if updated_person %}
{% include "familytree/face_name_link.html" with person=updated_person %}
{% elif updated_story %}
<a href="{% url 'story' updated_story.id %}">this story
<img src="{% static 'familytree/book.png' %}" height="30"/>
</a>
{% elif content_type == 'family' %}
<a href="{% url 'family_detail' update.object_id %}">{{ update.object_repr }}</a>
{% elif content_type == 'story' %}
Expand Down
11 changes: 8 additions & 3 deletions mysite/familytree/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def index(request): # dashboard page
)

# only include additions or updates, for family, person, story, notes
display_action_types = [1, 2]
display_action_types = [1, 2] # added, updated
display_update_types = [2, 4, 5, 9]
recent_logentries = LogEntry.objects.filter(
content_type_id__in=display_update_types, action_flag__in=display_action_types
Expand All @@ -89,15 +89,20 @@ def index(request): # dashboard page
update_author = update.user
user_person = Profile.objects.get(user=update_author).person
updated_person = None
updated_story = None

if update.content_type_id == 4:
if update.content_type_id == 4: # Person update
updated_person = Person.objects.get(id=update.object_id)

if update.content_type_id == 5: # Story update (including association with person/family)
updated_story = Story.objects.get(id=update.object_id)

content_type = str(ContentType.objects.get(id=update.content_type_id)).replace(
"familytree | ", ""
)
change_type = "added" if update.action_flag == 1 else "updated"
combination = [update, user_person, content_type, change_type, updated_person]
updated_story = Story.objects.get(id=update.object_id)
combination = [update, user_person, content_type, change_type, updated_person, updated_story ]
recent_updates.append(combination)

# get list of people with birthdays this month
Expand Down

0 comments on commit e609daa

Please sign in to comment.