Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle story updates in dashboard updates view #276

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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