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

added filter issue by open or close status #189

Merged
merged 2 commits into from
Oct 26, 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
26 changes: 25 additions & 1 deletion home/templates/dashboard/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
display: none;
position: absolute;
left: 100%;
top: 0;
margin-top: 5;
}

Expand Down Expand Up @@ -89,7 +90,13 @@
<li>
<a class="dropdown-item" href="#">
Difficulty &raquo;
<button type="button" disabled class="btn btn-danger btn-sm">{{ curr_difficulty }}</button>
<button type="button" disabled class="btn btn-danger btn-sm">
{%if curr_difficulty%}
{{ curr_difficulty }}
{%else%}
ALL
{%endif%}
</button>
</a>
<ul class="dropdown-menu dropdown-submenu">
<li><a class="dropdown-item" href="{% url 'filter_by_difficulty' 'All' %}">All</a></li>
Expand Down Expand Up @@ -138,6 +145,23 @@
{% endfor %}
</ul>
</li>
<li>
<a class="dropdown-item" href="#">
Status &raquo;
<button type="button" disabled class="btn btn-danger btn-sm">
{%if curr_status%}
{{ curr_status }}
{%else%}
ALL
{%endif%}
</button>
</a>
<ul class="dropdown-menu dropdown-submenu">
<li><a class="dropdown-item" href="{% url 'filter_by_status' 'All' %}">All</a></li>
<li><a class="dropdown-item" href="{% url 'filter_by_status' 'Open' %}">Open</a></li>
<li><a class="dropdown-item" href="{% url 'filter_by_status' 'Closed' %}">Closed</a></li>
</ul>
</li>
</ul>
</li>
<li class="nav-item">
Expand Down
2 changes: 2 additions & 0 deletions home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
path('contact/', views.contact_form, name='contact_form'),
path('like/<int:issue_pk>/', views.likes, name='like_issue'),
path('dislike/<int:issue_pk>/', views.dislikes, name='dislike_issue'),
path('filter_by_status/<str:status>/',
views.filter_by_status, name='filter_by_status'),
]
43 changes: 43 additions & 0 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,49 @@ def filter_by_difficulty(request, difficulty_level=None):
return render(request, 'dashboard/index.html', context=context)


@complete_profile_required
def filter_by_status(request, status=None):
"""
Filter the issues on basis of their open or close status.
params: selected filter option
return:
"""
issues_qs = Issue.objects.all()
project_qs = Project.objects.all()

if status and status != 'All':
status_mapping = {
'Open': Issue.OPEN,
'Closed': Issue.CLOSED
}
if status in status_mapping:
issues_qs = issues_qs.filter(state=status_mapping[status])

domains_qs = Domain.objects.all()
subdomains_qs = SubDomain.objects.all()

curr_domain = request.GET.get('domain', 'All')
curr_subdomain = request.GET.get('subdomain', 'All')

if curr_domain != 'All':
issues_qs = issues_qs.filter(project__domain__name=curr_domain)

if curr_subdomain != 'All':
issues_qs = issues_qs.filter(project__subdomain__name=curr_subdomain)

context = {
'projects': project_qs,
'issues': issues_qs,
'domains': domains_qs,
'subdomains': subdomains_qs,
'curr_domain': curr_domain,
'curr_subdomain': curr_subdomain,
'curr_status': status if status else 'All'
}

return render(request, 'dashboard/index.html', context=context)


def authorize(request):
"""
Used for rendering authorize.html which is responsible for both LogIn and SignUp
Expand Down
18 changes: 18 additions & 0 deletions project/migrations/0042_alter_issue_levelcolor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1 on 2024-10-24 16:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('project', '0041_issue_levelcolor'),
]

operations = [
migrations.AlterField(
model_name='issue',
name='levelcolor',
field=models.PositiveSmallIntegerField(choices=[(0, '#f2f2f2'), (4, '#39c0ed'), (1, '#00b74a'), (2, '#ffa900'), (3, '#f93154')], default=1, verbose_name='Level Color'),
),
]
Loading