Skip to content

Commit

Permalink
total reactions per project
Browse files Browse the repository at this point in the history
  • Loading branch information
rowidanagah committed Mar 18, 2023
1 parent a234d34 commit f0c4ce7
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 21 deletions.
95 changes: 74 additions & 21 deletions home/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,69 @@ <h6>Our top rated projects so far</h6>
</div>
<h2 class="sec-title__title">top rated projects</h2>
</div>
{%for rated_proj in all_rates %}
{%if rated_proj.avg_rate %}
<!--Start Feature One Single-->
<div class="col-xl-4 col-lg-4 wow animated fadeInUp" data-wow-delay="0.2s">
<div class="feature-one__single text-center">
<div class="feature-one__single-icon">
{% for img in images %}
{% if img.project == rated_proj %}
<img src="{{ img.image.url }}" style="height:130px" alt="#">
{% endif %}
{% endfor %}
</div>
<div class="feature-one__single-content mt-5">
{% get_user_info rated_proj.user as user_info %}
<h2><a href={% url 'singleproject' rated_proj.id %}>{{rated_proj.title}}</a></h2>
<p>{{rated_proj.slug}} with {{rated_proj.avg_rate}}
<br> by {{user_info.username|capfirst}} {{user_info.last_name|capfirst}}
</p>
</p>
{%for project in all_rates %}
{%if project.avg_rate %}
<div class="col-xl-4 col-lg-4 wow fadeInUp" data-wow-delay=".3s">
<div class="blog-one__single">
<div class="blog-one__single-img">
<div class="inner">
{% for img in images %}
{% if img.project == project %}
<img src="{{ img.image.url }}" style="height:300px" alt="#">
{% endif %}
{% endfor %}
</div>
<ul class="overlay-text">
<li>
<p>{{project.avg_rate}}</p>
</li>
<li class="style2">
<p>{{project.created_at|date:'d M'}}</p>
</li>
</ul>
</div>
<div class="blog-one__single-content">
<div class="white-bg"></div>
<div class="left-bg"></div>
<div class="right-bg"></div>
<ul class="meta-box">
<li>
<div class="icon">
<span class="icon-user"></span>
</div>
<div class="text">
<p><a href="#">By {{project.user|capfirst}}</a></p>
</div>
</li>
<li>
<div class="icon">
<span class="icon-comment-outline"></span>
</div>
<div class="text">
{% load custom_tags %}
<p><a href="{% url 'singleproject' project.id %}"> {% get_method project %} Comment</a></p>
</div>
</li>
</ul>
<h2><a href={% url 'singleproject' project.id%}>{{project.title}}<br> International UK</a></h2>
<div class="blog-one__single-content-bottom">
<div class="btn-box">
<a href={% url 'singleproject' project.id %}>Details More <span
class="icon-right-arrow21"></span></a>
</div>
<div class="icon-box">
{% get_user_react_on_project project as user_reaction %}
{% if user_reaction %}
<a href={% url 'like_project' project.id %}>
<i class="fa-solid fa-heart fa-2x like"></i>
</a>
{% else %}
<a href={% url 'like_project' project.id %}>
<i class="fa-regular fa-heart"></i>
</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -627,7 +671,7 @@ <h2 class="sec-title__title">Latest News & Projects</h2>
</div>
<ul class="overlay-text">
<li>
<p>Charity</p>
<p>{{project.category}}</p>
</li>
<li class="style2">
<p>{{project.created_at|date:'d M'}}</p>
Expand All @@ -644,7 +688,7 @@ <h2 class="sec-title__title">Latest News & Projects</h2>
<span class="icon-user"></span>
</div>
<div class="text">
<p><a href="#">By Admin</a></p>
<p><a href="#">By {{project.user|capfirst}}</a></p>
</div>
</li>
<li>
Expand All @@ -656,6 +700,15 @@ <h2 class="sec-title__title">Latest News & Projects</h2>
<p><a href="{% url 'singleproject' project.id %}"> {% get_method project %} Comment</a></p>
</div>
</li>
<li class="mt-1">
<div class="icon">
<span ><i class="fa-regular fa-thumbs-up"></i></span>
</div>
<div class="text">
{% load custom_tags %}
<p><a href="{% url 'singleproject' project.id %}"> {% get_project_total_reactions project %} reactions</a></p>
</div>
</li>
</ul>
<h2><a href={% url 'singleproject' project.id%}>{{project.title}}<br> International UK</a></h2>
<div class="blog-one__single-content-bottom">
Expand Down
6 changes: 6 additions & 0 deletions home/templatetags/custom_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def get_method(project):
return Comments.get_project_number_of_comments(project)


@register.simple_tag
def get_project_total_reactions(project):
total_reactions = likes.get_project_likes_number(project)
return total_reactions if total_reactions else 0


@register.simple_tag
def recently_created_projects():
return Project.get_recently_created_projects()
Expand Down

0 comments on commit f0c4ce7

Please sign in to comment.