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

Allow to resend vouchers by email #1812

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sohalt
Copy link
Contributor

@Sohalt Sohalt commented Oct 17, 2020

Closes #1748

Currently it just sends a generic message. It would be nice to somehow reuse the old message or have the old message template as a starting point for composing a new message.

# FIXME We can't get the original subject
subject = gettext('Resent Voucher')
# FIXME We can't get the original message
message = LazyI18nString('We are resending you your voucher for {event}: {voucher_list}')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't get translated this way, does it?
Should I do this?:

Suggested change
message = LazyI18nString('We are resending you your voucher for {event}: {voucher_list}')
message = LazyI18nString(_('We are resending you your voucher for {event}: {voucher_list}'))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the correct way is using LazyI18nString.from_gettext, see for example pretix/base/settings.py for usage

locale=event.settings.locale,
)
v.log_action(
'pretix.voucher.sent',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should resending be a separate action from sending?

@@ -285,6 +285,29 @@ def get(self, request, *args, **kwargs):
return redirect('control:event.vouchers', event=request.event.slug, organizer=request.event.organizer.slug)


class VoucherResend(EventPermissionRequiredMixin, View):
permission = 'can_change_vouchers'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does resending count as changing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@@ -421,6 +444,20 @@ def post(self, request, *args, **kwargs):
obj.max_usages = min(obj.redeemed, obj.max_usages)
obj.save(update_fields=['max_usages'])
messages.success(request, _('The selected vouchers have been deleted or disabled.'))
elif request.POST.get('action') == 'resend':
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If resending does not count as changing, this would need different permissions.

follow=True)
assert doc.select(".alert-danger")

# TODO test bulk resend
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any other testcases that test bulk functionality, so I didn't write any myself

@codecov
Copy link

codecov bot commented Oct 17, 2020

Codecov Report

Merging #1812 into master will decrease coverage by 0.00%.
The diff coverage is 72.97%.

@@            Coverage Diff             @@
##           master    #1812      +/-   ##
==========================================
- Coverage   79.29%   79.29%   -0.01%     
==========================================
  Files         320      320              
  Lines       37972    38006      +34     
==========================================
+ Hits        30111    30136      +25     
- Misses       7861     7870       +9     
Impacted Files Coverage Δ
src/pretix/base/orderimport.py 91.93% <0.00%> (ø)
src/pretix/plugins/checkinlists/exporters.py 56.50% <ø> (ø)
src/pretix/control/views/vouchers.py 81.46% <55.00%> (-2.06%) ⬇️
src/pretix/base/models/vouchers.py 95.19% <100.00%> (+0.02%) ⬆️
src/pretix/base/services/vouchers.py 97.56% <100.00%> (+1.26%) ⬆️

@raphaelm
Copy link
Member

I'm so sorry I didn't get around reviewing this yet :( Things are a little busy here and I still have some design concerns here that I need to spend some time thinking about. Hope things get better soon. Sorry again!

@Sohalt
Copy link
Contributor Author

Sohalt commented Nov 17, 2020

No worries, take your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resend voucher
2 participants