Skip to content

Commit

Permalink
Renated the tabs in author page and removed unneeded and sometimes in…
Browse files Browse the repository at this point in the history
…nacurate (you can sort by oldest) "lastest [media type] from [author name]" title
  • Loading branch information
SamuelmdLow committed Oct 23, 2024
1 parent c76b30c commit c19eb1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
20 changes: 8 additions & 12 deletions authors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AuthorPage(RoutablePageMixin, Page):



CHOICES = [("articles", "Articles"), ("photos", "Photos"), ("videos", "Videos"), ('visual-bylines', "Visual Bylines")]
CHOICES = [("articles", "Articles"), ("photos", "Gallery"), ("videos", "Videos"), ('visuals', "Visual Bylines")]
main_media_type = models.CharField(
choices=CHOICES,
default='articles',
Expand Down Expand Up @@ -193,7 +193,7 @@ def organize_media(self, media_type, request, context):
authors_media = UbysseyImage.objects.filter(author=self).order_by(article_order+"updated_at")
elif media_type == "videos":
authors_media = VideoSnippet.objects.filter(video_authors__author=self).order_by(article_order+"updated_at")
elif media_type == "visual-bylines":
elif media_type == "visuals":
# Get articles where this author is credited with something other than "author" and "org_role"
authors_media = []
keys = []
Expand Down Expand Up @@ -238,7 +238,7 @@ def organize_media(self, media_type, request, context):
paginated_articles = paginator.page(paginator.num_pages)
context["current_page"] = paginator.num_pages

if media_type == "visual-bylines" or "articles":
if media_type == "visuals" or "articles":
context['is_orderable'] = True
context["paginated_articles"] = paginated_articles

Expand All @@ -255,9 +255,9 @@ def get_context(self, request, *args, **kwargs):
if ArticleAuthorsOrderable.objects.filter(author=self, author_role="author").exists():
media_types.append(("articles", "articles"))
if ArticleAuthorsOrderable.objects.filter(author=self).exclude(author_role="author").exists():
media_types.append(("visual-bylines", "visual bylines"))
media_types.append(("visuals", "visuals"))
if UbysseyImage.objects.filter(author=self).exists():
media_types.append(("photos", "photos"))
media_types.append(("photos", "gallery"))
if VideoAuthorsOrderable.objects.filter(author=self).exists():
media_types.append(("videos", "videos"))

Expand Down Expand Up @@ -352,24 +352,22 @@ def stories_page(self, request, *args, **kwargs):
context = self.get_context(request, *args, **kwargs)

context["media_type"] = "articles"
context["media_type_name"] = "articles"

context = self.organize_media("articles", request, context)

return render(request, self.template, context)

@route(r'^visual-bylines/$')
@route(r'^visuals/$')
def visuals_page(self, request, *args, **kwargs):
"""
View function for author's stories
"""

context = self.get_context(request, *args, **kwargs)

context["media_type"] = "visual-bylines"
context["media_type_name"] = "visual bylines"
context["media_type"] = "visuals"

context = self.organize_media("visual-bylines", request, context)
context = self.organize_media("visuals", request, context)

return render(request, self.template, context)

Expand All @@ -382,7 +380,6 @@ def photos_page(self, request, *args, **kwargs):
context = self.get_context(request, *args, **kwargs)

context["media_type"] = "photos"
context["media_type_name"] = "photos"

context = self.organize_media("photos", request, context)

Expand All @@ -397,7 +394,6 @@ def videos_page(self, request, *args, **kwargs):
context = self.get_context(request, *args, **kwargs)

context["media_type"] = "videos"
context["media_type_name"] = "videos"

context = self.organize_media("videos", request, context)

Expand Down
4 changes: 1 addition & 3 deletions authors/templates/authors/author_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ <h2 class="author-heading {% if media_type == type.0 %}selected{% endif %}"><a h
{% endfor %}
</div>

<h2 class="author-heading">Latest {{media_type_name}} from {{self.title}}</h2>

{% if media_type == "articles" or media_type == "visual-bylines" %}
{% if media_type == "articles" or media_type == "visuals" %}
{% include 'archive/objects/archive.html' with page_obj=paginated_articles current_page_articles=current_page_articles %}
{% elif media_type == "photos" %}
{% include 'archive/objects/gallery.html' with page_obj=paginated_articles %}
Expand Down

0 comments on commit c19eb1d

Please sign in to comment.