Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Added missing code for redirection and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sab-LC committed Oct 18, 2023
1 parent cdda7b4 commit 2cdba73
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions communities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django_countries.fields import CountryField
from institutions.models import Institution
import uuid
from itertools import chain
import os

class ApprovedManager(models.Manager):
Expand Down Expand Up @@ -74,6 +75,11 @@ def get_collaborator(self):
def __str__(self):
return str(self.community_name)

@property
def approved_label(self):
approved_label = (self.tklabel_community.filter(is_approved=True).first() or self.bclabel_community.filter(is_approved=True).first())
return approved_label

class Meta:
indexes = [models.Index(fields=['id', 'community_creator', 'image'])]
verbose_name = 'Community'
Expand Down
5 changes: 5 additions & 0 deletions institutions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def get_distinct_creators(self):
def __str__(self):
return str(self.institution_name)

@property
def institution_projects(self):
institution_projects = self.institution_created_project.filter(institution=self)
return institution_projects

class Meta:
indexes = [models.Index(fields=['id', 'institution_creator', 'image'])]
verbose_name = 'Institution'
Expand Down
4 changes: 2 additions & 2 deletions templates/accounts/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

{% if user_communities %}
{% for community in user_communities %}
{% include 'partials/infocards/_community-card.html' %}
{% include 'partials/infocards/_community-card.html' with approved_label=community.approved_label %}
{% endfor %}
{% endif %}

{% if user_institutions %}
{% for institution in user_institutions %}
{% include 'partials/infocards/_institution-card.html' %}
{% include 'partials/infocards/_institution-card.html' with institution_projects=institution.institution_projects %}
{% endfor %}
{% endif %}

Expand Down
4 changes: 0 additions & 4 deletions templates/partials/infocards/_community-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
{% endif %}

{% if '/dashboard/' in request.path %}
<a
class="primary-btn action-btn"
href="{% url 'select-label' community.id %}"
>View account</a>
{% if approved_label %}
{% if request.user in community.get_collaborator or request.user == community.community_creator %}
<a class="primary-btn action-btn" href="{% url 'community-projects' community.id %}">View account</a>
Expand Down
1 change: 0 additions & 1 deletion templates/partials/infocards/_institution-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
{% endif %}

{% if '/dashboard/' in request.path %}
<a
{% if institution_projects %}
{% if request.user in institution.get_distinct_creators %}
<a
Expand Down

0 comments on commit 2cdba73

Please sign in to comment.