Update trade offer acceptance update template buttons to have better text and styling
This commit is contained in:
parent
fb9f2f5848
commit
2451a6c630
3 changed files with 67 additions and 8 deletions
|
|
@ -143,6 +143,35 @@ class TradeAcceptance(models.Model):
|
|||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
# A mapping for alternate action labels
|
||||
ALTERNATE_ACTION_LABELS = {
|
||||
AcceptanceState.REJECTED_BY_INITIATOR: "Cancel This Trade",
|
||||
AcceptanceState.REJECTED_BY_ACCEPTOR: "Cancel This Trade",
|
||||
# Optionally add alternate labels for other states:
|
||||
AcceptanceState.ACCEPTED: "Accept This Trade Offer",
|
||||
AcceptanceState.SENT: "Mark as Sent",
|
||||
AcceptanceState.RECEIVED: "Mark as Received",
|
||||
AcceptanceState.THANKED_BY_INITIATOR: "Send Thanks",
|
||||
AcceptanceState.THANKED_BY_ACCEPTOR: "Send Thanks",
|
||||
AcceptanceState.THANKED_BY_BOTH: "Send Thanks",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def get_action_label_for_state(cls, state_value):
|
||||
"""
|
||||
Returns the alternate action label for the provided state_value.
|
||||
If no alternate label exists, falls back to the default label.
|
||||
"""
|
||||
default = dict(cls.AcceptanceState.choices).get(state_value, state_value)
|
||||
return cls.ALTERNATE_ACTION_LABELS.get(state_value, default)
|
||||
|
||||
@property
|
||||
def action_label(self):
|
||||
"""
|
||||
For the current acceptance state, return the alternate action label.
|
||||
"""
|
||||
return self.get_action_label_for_state(self.state)
|
||||
|
||||
@property
|
||||
def is_completed(self):
|
||||
return self.state in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue