set emails list

This commit is contained in:
PierreDubrulle 2024-01-18 17:33:04 +01:00 committed by Alexis Metaireau
parent a11620f143
commit 6b8eecdb6e
4 changed files with 12 additions and 13 deletions

View file

@ -140,7 +140,7 @@
<a class="button is-info" href="{% url 'order:email_list' grouped_order.code %}?format=csv" target="_blank">
<i class="fa fa-file-excel-o mr-3" aria-hidden="true"></i>Emails en CSV
</a>
<input id="email_list" name="email_list" hidden="true" value="{% for order in grouped_order.order_set.all %}{{ order.author.email }}{% endfor %}" />
<input id="email_list" name="email_list" hidden="true" value="{{ emails_list|join:';' }}" />
<a class="button is-info" onclick="copyText('email_list')" target="_blank">
<i class="fa fa-files-o mr-3" aria-hidden="true"></i>Copier les emails
</a>
@ -277,14 +277,17 @@
<script>
{% block extra_js %}
var previousCopied = null;
var previousHtmlCopied = null;
// Copy grouped order link
// Copy grouped order text
function copyText(elementId) {
var element = document.getElementById(elementId);
var text = element.value;
navigator.clipboard.writeText(text).then(function() {
console.log('Copying to clipboard was successful!');
console.debug('Copying to clipboard was successful!');
console.debug('Copied text: ', text);
var button = document.querySelector('[onclick="copyText(\'' + elementId + '\')"]');
if (button !== null) {
if (previousCopied !== null) {
@ -298,13 +301,6 @@
console.error('Could not copy text: ', err);
});
}
// function copyLink() {
// var copyText = document.getElementById("shareLink");
// copyText.select();
// copyText.setSelectionRange(0, 99999); // For mobile devices
// navigator.clipboard.writeText(copyText.value);
// }
// Tabs
function openTab(idToOpen) {
var i, tabcontent, tablinks;

View file

@ -1398,7 +1398,7 @@ class TestExportGroupedOrderEmailAddressesToCSVView:
assert response.status_code == 200
assert (
response.content.decode()
== '{"order_name": "gr order test", "email_list": []}'
== ''
)
email = order_items_in_grouped_order(grouped_order).author.email

View file

@ -151,6 +151,10 @@ class GroupedOrderOverview(UserPassesTestMixin, generic.DetailView):
context["share_link"] = self.request.build_absolute_uri(
reverse("order:grouped_order_detail", args=(self.get_object().code,))
)
participants = OrderAuthor.objects.filter(
order__in=self.get_object().order_set.all()
)
context["emails_list"] = set(participant.email for participant in participants)
return context
@ -333,7 +337,7 @@ class ExportGroupOrderEmailAdressesToDownloadView(UserPassesTestMixin, generic.V
participants = OrderAuthor.objects.filter(
order__in=grouped_order.order_set.all()
)
email_list = [participant.email for participant in participants]
email_list = set(participant.email for participant in participants)
format = self.request.GET.get("format", "json")
if format == "csv":

View file

@ -11,7 +11,6 @@
<meta property="og:locale" content="fr_FR" />
<meta property="og:site_name" content="La chariotte">
<meta property="og:url" content="{{ BASE_URL }}{{ request.path }}">
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
<title>{% block title %}{% endblock %} - La Chariotte</title>
{% block css %}