Skip to content

Commit

Permalink
punch commission state redirect into commissions component view context
Browse files Browse the repository at this point in the history
  • Loading branch information
mrf7777 committed Jan 31, 2024
1 parent 3f1b516 commit 4863d74
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 20 deletions.
3 changes: 2 additions & 1 deletion furfolio/templates/furfolio/commissions/commission_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
hide_buyer: (bool) if True, and is not self-manged, hide the buyer
hide_creator: (bool) if True, and is not self-managed, hide the creator
hide_redundant_users: (bool) If true, equivallent to setting hide_buyer and hide_creator smartly based on the signed in user. If True, ignores hide_buyer and hide_creator.
next: (optional) when setting commission state or updating other info, where to redirect to
{% endcomment %}

{% load static %}
Expand Down Expand Up @@ -50,7 +51,7 @@ <h6 class="mb-0">
</div>

<div class="card-footer">
{% include "./commission_functions.html" with commission=commission csrf_token=csrf_token request=request fill=True only %}
{% include "./commission_functions.html" with commission=commission csrf_token=csrf_token request=request fill=True next=next only %}
</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- request: the request object
- fill: (bool) if True, will put functions and state buttons as far apart as possible.
- some_space_between_functions: (bool) if True, will force add margin between commission functions
- next: (optional) when setting state of commission or submitting form, where to redirect to
{% endcomment %}

<div class="d-flex flex-wrap align-items-center">
Expand All @@ -30,26 +31,26 @@
</button>
<div class="fs-5 dropdown-menu">
{% if commission.state == "REVIEW" %}
<div class="m-3">{% include "furfolio/commissions/state_buttons/state_setters/accept.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3">{% include "furfolio/commissions/state_buttons/state_setters/reject.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3">{% include "furfolio/commissions/state_buttons/state_setters/accept.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
<div class="m-3">{% include "furfolio/commissions/state_buttons/state_setters/reject.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
{% endif %}

{% if commission.state == "ACCEPTED" %}
<div class="m-3 mb-4">{% include "furfolio/commissions/state_buttons/state_setters/in_progress.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3" style="font-size: 0.65em">{% include "furfolio/commissions/state_buttons/state_setters/review.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3 mb-4">{% include "furfolio/commissions/state_buttons/state_setters/in_progress.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
<div class="m-3" style="font-size: 0.65em">{% include "furfolio/commissions/state_buttons/state_setters/review.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
{% endif %}

{% if commission.state == "IN_PROGRESS" %}
<div class="m-3 mb-4" >{% include "furfolio/commissions/state_buttons/state_setters/close.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3" style="font-size: 0.65em">{% include "furfolio/commissions/state_buttons/state_setters/accept.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3 mb-4" >{% include "furfolio/commissions/state_buttons/state_setters/close.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
<div class="m-3" style="font-size: 0.65em">{% include "furfolio/commissions/state_buttons/state_setters/accept.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
{% endif %}

{% if commission.state == "CLOSED" %}
<div class="m-3" style="font-size: 0.65em">{% include "furfolio/commissions/state_buttons/state_setters/in_progress.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3" style="font-size: 0.65em">{% include "furfolio/commissions/state_buttons/state_setters/in_progress.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
{% endif %}

{% if commission.state == "REJECTED" %}
<div class="m-3">{% include "furfolio/commissions/state_buttons/state_setters/accept.html" with commission=commission request=request csrf_token=csrf_token only %}</div>
<div class="m-3">{% include "furfolio/commissions/state_buttons/state_setters/accept.html" with commission=commission request=request csrf_token=csrf_token next=next only %}</div>
{% endif %}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- commission: the commission to change the state of when this button is pressed
- request: the request object
- csrf_token: the csrf token
- next: (optional) the url to go to when set
{% endcomment %}

<form method="post" action="{% url "update_commission_status" commission.pk %}?next={{ request.get_full_path|urlencode }}">
<form method="post" action="{% url "update_commission_status" commission.pk %}?next={% if next %}{{ next }}{% else %}{{ request.get_full_path|urlencode }}{% endif %}">
{% csrf_token %}
<input type="hidden" value="ACCEPTED" name="state">
{% include "../accept.html" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- commission: the commission to change the state of when this button is pressed
- request: the request object
- csrf_token: the csrf token
- next: (optional) the url to go to when set
{% endcomment %}

<form method="post" action="{% url "update_commission_status" commission.pk %}?next={{ request.get_full_path|urlencode }}">
<form method="post" action="{% url "update_commission_status" commission.pk %}?next={% if next %}{{ next }}{% else %}{{ request.get_full_path|urlencode }}{% endif %}">
{% csrf_token %}
<input type="hidden" value="CLOSED" name="state">
{% include "../close.html" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- commission: the commission to change the state of when this button is pressed
- request: the request object
- csrf_token: the csrf token
- next: (optional) the url to go to when set
{% endcomment %}

<form method="post" action="{% url "update_commission_status" commission.pk %}?next={{ request.get_full_path|urlencode }}">
<form method="post" action="{% url "update_commission_status" commission.pk %}?next={% if next %}{{ next }}{% else %}{{ request.get_full_path|urlencode }}{% endif %}">
{% csrf_token %}
<input type="hidden" value="IN_PROGRESS" name="state">
{% include "../in_progress.html" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- commission: the commission to change the state of when this button is pressed
- request: the request object
- csrf_token: the csrf token
- next: (optional) the url to go to when set
{% endcomment %}

<form method="post" action="{% url "update_commission_status" commission.pk %}?next={{ request.get_full_path|urlencode }}">
<form method="post" action="{% url "update_commission_status" commission.pk %}?next={% if next %}{{ next }}{% else %}{{ request.get_full_path|urlencode }}{% endif %}">
{% csrf_token %}
<input type="hidden" value="REJECTED" name="state">
{% include "../reject.html" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- commission: the commission to change the state of when this button is pressed
- request: the request object
- csrf_token: the csrf token
- next: (optional) the url to go to when set
{% endcomment %}

<form method="post" action="{% url "update_commission_status" commission.pk %}?next={{ request.get_full_path|urlencode }}">
<form method="post" action="{% url "update_commission_status" commission.pk %}?next={% if next %}{{ next }}{% else %}{{ request.get_full_path|urlencode }}{% endif %}">
{% csrf_token %}
<input type="hidden" value="REVIEW" name="state">
{% include "../review.html" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
- commissions: a list of commission objects
- request: the request object
- csrf_token: the csrf_token
- next: (optional) when updating commission state or other info, where to redirect to
{% endcomment %}

{% if commissions %}
{% for commission in commissions %}
<div class="mb-3">
{% include "furfolio/commissions/commission_card.html" with commission=commission request=request csrf_token=csrf_token hide_redundant_users=True only %}
{% include "furfolio/commissions/commission_card.html" with commission=commission request=request csrf_token=csrf_token hide_redundant_users=True next=next only %}
</div>
{% endfor %}
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endblock %}

{% block column_1 %}
{% include "./commission_card_list.html" with commissions=review_commissions request=request csrf_token=csrf_token only %}
{% include "./commission_card_list.html" with commissions=review_commissions request=request csrf_token=csrf_token next=next only %}
{% endblock %}


Expand All @@ -32,7 +32,7 @@
{% endblock %}

{% block column_2 %}
{% include "./commission_card_list.html" with commissions=accepted_commissions request=request csrf_token=csrf_token only %}
{% include "./commission_card_list.html" with commissions=accepted_commissions request=request csrf_token=csrf_token next=next only %}
{% endblock %}


Expand All @@ -48,5 +48,5 @@
{% endblock %}

{% block column_3 %}
{% include "./commission_card_list.html" with commissions=in_progress_commissions request=request csrf_token=csrf_token only %}
{% include "./commission_card_list.html" with commissions=in_progress_commissions request=request csrf_token=csrf_token next=next only %}
{% endblock %}
5 changes: 3 additions & 2 deletions furfolio/templates/furfolio/dashboards/creator.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "furfolio/layouts/title_body.html" %}

{% load static %}
{% load query_replace %}

{% block title %}
{% endblock %}
Expand Down Expand Up @@ -40,8 +41,8 @@
</form>

<div
hx-get="{% url "dashboard_commissions_component" %}"
hx-trigger="every 4s"
hx-get="{% url "dashboard_commissions_component" %}?{% query_replace request "next" request.get_full_path %}"
hx-trigger="every 10s"
>
{% include "./commissions_component.html" %}
</div>
Expand Down
1 change: 1 addition & 0 deletions furfolio/views/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
CreatorDashboard.MAX_COMMISSIONS_PER_COLUMN,
self.request.GET,
)
context["next"] = self.request.GET.get("next")
return context

0 comments on commit 4863d74

Please sign in to comment.