mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-02 11:52:27 +02:00
set emails list
This commit is contained in:
parent
a11620f143
commit
6b8eecdb6e
4 changed files with 12 additions and 13 deletions
|
@ -140,7 +140,7 @@
|
||||||
<a class="button is-info" href="{% url 'order:email_list' grouped_order.code %}?format=csv" target="_blank">
|
<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
|
<i class="fa fa-file-excel-o mr-3" aria-hidden="true"></i>Emails en CSV
|
||||||
</a>
|
</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">
|
<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
|
<i class="fa fa-files-o mr-3" aria-hidden="true"></i>Copier les emails
|
||||||
</a>
|
</a>
|
||||||
|
@ -277,14 +277,17 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
|
|
||||||
var previousCopied = null;
|
var previousCopied = null;
|
||||||
var previousHtmlCopied = null;
|
var previousHtmlCopied = null;
|
||||||
// Copy grouped order link
|
|
||||||
|
// Copy grouped order text
|
||||||
function copyText(elementId) {
|
function copyText(elementId) {
|
||||||
var element = document.getElementById(elementId);
|
var element = document.getElementById(elementId);
|
||||||
var text = element.value;
|
var text = element.value;
|
||||||
navigator.clipboard.writeText(text).then(function() {
|
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 + '\')"]');
|
var button = document.querySelector('[onclick="copyText(\'' + elementId + '\')"]');
|
||||||
if (button !== null) {
|
if (button !== null) {
|
||||||
if (previousCopied !== null) {
|
if (previousCopied !== null) {
|
||||||
|
@ -298,13 +301,6 @@
|
||||||
console.error('Could not copy text: ', err);
|
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
|
// Tabs
|
||||||
function openTab(idToOpen) {
|
function openTab(idToOpen) {
|
||||||
var i, tabcontent, tablinks;
|
var i, tabcontent, tablinks;
|
||||||
|
|
|
@ -1398,7 +1398,7 @@ class TestExportGroupedOrderEmailAddressesToCSVView:
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert (
|
assert (
|
||||||
response.content.decode()
|
response.content.decode()
|
||||||
== '{"order_name": "gr order test", "email_list": []}'
|
== ''
|
||||||
)
|
)
|
||||||
|
|
||||||
email = order_items_in_grouped_order(grouped_order).author.email
|
email = order_items_in_grouped_order(grouped_order).author.email
|
||||||
|
|
|
@ -151,6 +151,10 @@ class GroupedOrderOverview(UserPassesTestMixin, generic.DetailView):
|
||||||
context["share_link"] = self.request.build_absolute_uri(
|
context["share_link"] = self.request.build_absolute_uri(
|
||||||
reverse("order:grouped_order_detail", args=(self.get_object().code,))
|
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
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,7 +337,7 @@ class ExportGroupOrderEmailAdressesToDownloadView(UserPassesTestMixin, generic.V
|
||||||
participants = OrderAuthor.objects.filter(
|
participants = OrderAuthor.objects.filter(
|
||||||
order__in=grouped_order.order_set.all()
|
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")
|
format = self.request.GET.get("format", "json")
|
||||||
if format == "csv":
|
if format == "csv":
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
<meta property="og:locale" content="fr_FR" />
|
<meta property="og:locale" content="fr_FR" />
|
||||||
<meta property="og:site_name" content="La chariotte">
|
<meta property="og:site_name" content="La chariotte">
|
||||||
<meta property="og:url" content="{{ BASE_URL }}{{ request.path }}">
|
<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>
|
<title>{% block title %}{% endblock %} - La Chariotte</title>
|
||||||
{% block css %}
|
{% block css %}
|
||||||
|
|
Loading…
Reference in a new issue