-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
85 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,7 @@ | |
"rules.apps.AutodiscoverRulesConfig", | ||
"organizations", | ||
"taggit", | ||
"django_filters", | ||
] | ||
|
||
LOCAL_APPS = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import django_filters | ||
from taggit.forms import TagField | ||
|
||
from .forms import ProjectSearchForm | ||
from .models import Project | ||
|
||
|
||
class TagFilter(django_filters.CharFilter): | ||
field_class = TagField | ||
|
||
def __init__(self, *args, **kwargs): | ||
kwargs.setdefault("lookup_expr", "in") | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class ProjectFilter(django_filters.FilterSet): | ||
tags = TagFilter(field_name="tags__name") | ||
|
||
class Meta: | ||
model = Project | ||
form = ProjectSearchForm | ||
fields = ["status", "topics", "category", "departments", "customer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Submit | ||
from django import forms | ||
|
||
from .models import Project | ||
|
||
|
||
class ProjectSearchForm(forms.ModelForm): | ||
class Meta: | ||
model = Project | ||
fields = ["status", "topics", "category", "departments", "customer"] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.helper = FormHelper() | ||
self.helper.form_method = "get" | ||
|
||
self.helper.add_input(Submit("submit", "Search")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% load crispy_forms_tags %} | ||
|
||
{% block content %} | ||
<h2>Projects</h2> | ||
<div class="pb-5 mt-3 row"> | ||
<div class="col-3">{% crispy filter.form %}</div> | ||
<div class="col-9"> | ||
<ul class="list-group"> | ||
{% for project in object_list %} | ||
<li class="list-group-item"> | ||
<h5> | ||
<a href="{% url 'projects-detail' slug=project.slug %}">{{ project.name }}</a> | ||
</h5> | ||
<p>{{ project.description|default_if_none:'No description' }}</p> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
<div class="mt-3">{% include 'includes/pagination.html' %}</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters