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

Add publisher payout filter and sorting #979

Merged
merged 2 commits into from
Jan 22, 2025
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
7 changes: 7 additions & 0 deletions adserver/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from ..constants import PAID
from ..constants import PAYOUT_STRIPE
from ..constants import PUBLISHER_PAYOUT_METHODS
from ..mixins import StaffUserMixin
from ..models import Advertiser
from ..models import Publisher
Expand Down Expand Up @@ -91,6 +92,7 @@ class PublisherPayoutView(StaffUserMixin, TemplateView):
* first: Show only payouts for the first time
* paid: Show only payouts that have already been paid
* publisher: Filter to a specific publisher
* payout_method: Filter to a specific payout method
"""

template_name = "adserver/staff/publisher-payout-list.html"
Expand All @@ -103,10 +105,13 @@ def get_context_data(self, **kwargs):
publisher_slug = self.request.GET.get("publisher")
first = self.request.GET.get("first", "")
paid = self.request.GET.get("paid", "")
payout_method = self.request.GET.get("payout_method", "")

queryset = Publisher.objects.filter(skip_payouts=False)
if publisher_slug:
queryset = queryset.filter(slug__startswith=publisher_slug)
if payout_method:
queryset = queryset.filter(payout_method=payout_method)

payouts = {}

Expand Down Expand Up @@ -189,7 +194,9 @@ def get_context_data(self, **kwargs):
context["first"] = first
context["paid"] = paid
context["publisher_slug"] = publisher_slug
context["payout_method"] = payout_method
context["boolean_options"] = [["", "---"], ["True", "True"], ["False", "False"]]
context["payout_method_options"] = list(PUBLISHER_PAYOUT_METHODS)
return context


Expand Down
14 changes: 13 additions & 1 deletion adserver/templates/adserver/staff/publisher-payout-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
<input type="text" id="id_publisher" class="form-control text-monospace" name="publisher" value="{{ publisher_slug|default_if_none:"" }}"><br><br>
</div>

<div class="col-xl-3 col-md-6 col-12 mb-3">
<label class="col-form-label" for="id_payout_method">{% trans 'Payout Method' %}</label>
<select class="form-control" name="payout_method" id="id_payout_method">
<option value="">---</option>
{% for method, name in payout_method_options %}
<option value="{{ method }}"{% if payout_method == method %} selected{% endif %}>{{ name }}</option>
{% endfor %}
</select>
</div>

</div>

<button class="btn btn-primary" type="submit">{% trans 'Filter report' %}</button>
Expand All @@ -61,6 +71,7 @@
<th><strong>{% trans '% Change' %}</strong></th>
<th><strong>{% trans 'CTR' %}</strong></th>
<th><strong>{% trans 'Status' %}</strong></th>
<th><strong>{% trans 'Payout Method' %}</strong></th>
<th><strong>{% trans 'Action' %}</strong></th>
</tr>
</thead>
Expand Down Expand Up @@ -90,6 +101,7 @@
{% trans "Not started" %}
{% endif %}
</td>
<td>{{ publisher.get_payout_method_display }}</td>
<td>
{% if payout_data.payout and payout_data.payout.status == "paid" %}
No action required
Expand All @@ -101,7 +113,7 @@
</td>
</tr>
{% empty %}
<td colspan="7">{% trans 'No pending payouts' %}</td>
<td colspan="8">{% trans 'No pending payouts' %}</td>
{% endfor %}
</tbody>
</table>
Expand Down
Loading