Skip to content

Commit

Permalink
SS-1213 Combine recently updated and created apps into one list on th…
Browse files Browse the repository at this point in the history
…e homepage (#254)
  • Loading branch information
akochari authored Nov 26, 2024
1 parent 8163d0d commit f9e08bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 58 deletions.
22 changes: 4 additions & 18 deletions portal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,11 @@ class HomeView(View):
template = "portal/home.html"

def get(self, request, app_id=0):
all_published_apps_created_on, request = get_public_apps(
request, app_id=app_id, order_by="created_on", order_reverse=True
)
all_published_apps_updated_on, request = get_public_apps(
published_apps_updated_on, request = get_public_apps(
request, app_id=app_id, order_by="updated_on", order_reverse=True
)

# Make sure we don't have the same apps displayed in both Recently updated and Recently added fields
published_apps_created_on = [
app for app in all_published_apps_created_on if app.updated_on <= (app.created_on + timedelta(minutes=60))
][
:3
] # we display only 3 apps
published_apps_updated_on = [
app for app in all_published_apps_updated_on if app.updated_on > (app.created_on + timedelta(minutes=60))
][
:3
] # we display only 3 apps
)[
:6
] # we display only 6 apps

news_objects = NewsObject.objects.all().order_by("-created_on")
link_all_news = False
Expand Down Expand Up @@ -200,7 +187,6 @@ def get(self, request, app_id=0):

context = {
"published_apps_updated_on": published_apps_updated_on,
"published_apps_created_on": published_apps_created_on,
"news_objects": news_objects,
"link_all_news": link_all_news,
"collection_objects": collection_objects,
Expand Down
50 changes: 10 additions & 40 deletions templates/portal/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,12 @@ <h5 class="card-title">Development environments</h5>
<div class="row text-center justify-content-center border rounded bg-light mt-5">
<div class="col-12 text-center">
<h3 class="pt-4">Recent updates</h3>
<hr class="m-0 bg-lime border-0" style="height: 2px;">
</div>

{% for app in published_apps_updated_on %}
<div class="col-12 col-md-6 align-items-stretch mt-4 mb-2">
<h5>Recently updated</h5>
<hr class="m-0 bg-lime border-0" style="height: 2px;">
{% for app in published_apps_updated_on %}
<div class="card border-0 shadow my-5" data-aos="slide-up">
<div class="card-body text-start">
<div class="card-title d-flex justify-content-between align-items-center m-0">
<a href="{{ app.url }}" target="_blank">
<h5 class="">{{ app.name|truncatechars:30 }}</h5>
</a>
<div>
{% static 'images/logos/apps/' as static_url %}
<img style="height:40px;"
src="{{static_url}}{{app.app.logo}}"
alt="App Logo" title="{{app.app.name}}">
</div>
</div>
<div class="card-text">
{{ app.description|truncatechars:100 }}
</div>
</div>

<div class="card-footer d-flex text-muted card-footer-text justify-content-between bg-lime-025">
<div class="text-start">
<span>{{ app.app.name }}</span>
</div>
<div class="text-end">
<span>Last updated: {{ app.updated_on|date:"d M, Y" }}</span>
</div>
</div>
</div>
{% endfor %}
</div>

<div class="col-12 col-md-6 align-items-stretch mt-4 mb-2">
<h5>Recently created</h5>
<hr class="m-0 bg-teal border-0" style="height: 2px;">
{% for app in published_apps_created_on %}
<div class="card border-0 shadow my-5" data-aos="slide-up">
<div class="card border-0 shadow my-2" data-aos="slide-up">
<div class="card-body text-start">
<div class="card-title d-flex justify-content-between align-items-center m-0">
<a href="{{ app.url }}" target="_blank">
Expand All @@ -128,13 +93,18 @@ <h5 class="">{{ app.name|truncatechars:30 }}</h5>
<span>{{ app.app.name }}</span>
</div>
<div class="text-end">
{% if app.updated_on|date:'d M, Y' == app.created_on|date:'d M, Y' %}
<span>Created: {{ app.created_on|date:"d M, Y" }}</span>
{% else %}
<span>Updated: {{ app.updated_on|date:"d M, Y" }}</span>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<div class="col-12 text-center mb-2">
{% endfor %}

<div class="col-12 text-center my-2">
<a class="text-muted" href="{% url 'portal:apps' %}" target="_self" title="All apps and models">Browse all apps and models</a>
</div>
</div>
Expand Down

0 comments on commit f9e08bd

Please sign in to comment.