Skip to content

Commit

Permalink
Merge pull request digitalfox#93 from pyoupyou/source-list
Browse files Browse the repository at this point in the history
Add a processes list for a given source
  • Loading branch information
bport authored May 14, 2020
2 parents d609d12 + 4acefca commit 9d4f7ae
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.4.0 (2020-05-14)
- Add a page listing processes for a given source

# 1.3.0 (2020-02-24)
- Add sources to process admin
- Sort sources by name
Expand Down
10 changes: 9 additions & 1 deletion interview/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html


from interview.models import ContractType, Candidate, Document, Process, Interview, SourcesCategory, Sources, Offer

Expand Down Expand Up @@ -52,10 +55,15 @@ class SourcesCategoryAdmin(admin.ModelAdmin):

@admin.register(Sources)
class SourcesAdmin(admin.ModelAdmin):
list_display = ("id", "name", "category", "archived")
list_display = ("id", "name", "category", "archived", "processes_list_url")
list_filter = ("category", "archived")
search_fields = ("name",)

def processes_list_url(self, obj):
return format_html("<a href='{url}'>🔗</a>", url=reverse("process-list-source", args=[str(obj.id)]))

processes_list_url.short_description = "URL"


@admin.register(Offer)
class OfferAdmin(admin.ModelAdmin):
Expand Down
4 changes: 2 additions & 2 deletions interview/templates/interview/process_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ <h4> {% trans 'Process information' %}</h4>
<p>
{% if process.sources %}
<p>
<dt>{% trans "source" %}</dt>
<dd>{{ process.sources.category }} - {{ process.sources.name }}</dd>
<dt>{% trans "Source" %}</dt>
<dd><a href="{% url 'process-list-source' process.sources.id %}">{{ process.sources.name }} ({{ process.sources.category }})</a></dd>
</p>
{% endif %}
{% if process.offer %}
Expand Down
22 changes: 22 additions & 0 deletions interview/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,28 @@ def closed_processes(request):
return render(request, "interview/single_table.html", context)


@login_required
@require_http_methods(["GET"])
def processes_for_source(request, source_id):
try:
source = Sources.objects.get(id=source_id)
except Sources.DoesNotExist:
return HttpResponseNotFound()

processes = (
Process.objects.for_user(request.user).filter(sources_id=source_id).select_related("candidate", "contract_type")
)

processes_table = ProcessEndTable(processes, prefix="c")

config = RequestConfig(request)
config.configure(processes_table)

context = {"title": source.name + " (" + source.category.name + ")", "table": processes_table}

return render(request, "interview/single_table.html", context)


@login_required
@require_http_methods(["GET"])
def processes(request):
Expand Down
1 change: 1 addition & 0 deletions pyoupyou/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
url(r"^$", views.dashboard, name="dashboard"),
url(r"^processes/$", views.processes, name="process-list"),
url(r"^processes/closed$", views.closed_processes, name="process-closed-list"),
url(r"^processes/source/(?P<source_id>\d*)$", views.processes_for_source, name="process-list-source"),
url(r"^candidate/$", views.new_candidate, name="candidate-new"),
url(r"^import-seekube/$", views.import_seekube, name="import-seekube"),
url(r"^process/(?P<process_id>\d+)/$", views.process, name="process-details"),
Expand Down

0 comments on commit 9d4f7ae

Please sign in to comment.