lingo: make it possible to mark a basket item as not cancellable (#11144)
This commit is contained in:
parent
bdbef93bdf
commit
800c23eba1
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lingo', '0018_auto_20160527_0638'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='basketitem',
|
||||
name='user_cancellable',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
|
@ -191,6 +191,7 @@ class BasketItem(models.Model):
|
|||
details = models.TextField(verbose_name=_('Details'), blank=True)
|
||||
amount = models.DecimalField(verbose_name=_('Amount'),
|
||||
decimal_places=2, max_digits=8)
|
||||
user_cancellable = models.BooleanField(default=True)
|
||||
creation_date = models.DateTimeField(auto_now_add=True)
|
||||
cancellation_date = models.DateTimeField(null=True)
|
||||
payment_date = models.DateTimeField(null=True)
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
{% for item in items %}
|
||||
<li><label><input type="checkbox" name="item" value="{{ item.id }}" checked/>
|
||||
<a href="{{ item.source_url }}">{{ item.subject }}</a>: {{ item.amount }} €</label>
|
||||
<a rel="popup" href="{% url 'lingo-cancel-item' pk=item.id %}">({% trans 'remove' %}</a>)</li>
|
||||
{% if item.user_cancellable %}
|
||||
<a rel="popup" href="{% url 'lingo-cancel-item' pk=item.id %}">({% trans 'remove' %}</a>)
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><strong>{% trans "Total:" %}</strong> {{ total }} €</li>
|
||||
</ul>
|
||||
|
|
|
@ -130,6 +130,9 @@ class AddBasketItemApiView(View):
|
|||
# database...
|
||||
item.regie = Regie.objects.all()[0]
|
||||
|
||||
if request.GET.get('cancellable') == 'no':
|
||||
item.user_cancellable = False
|
||||
|
||||
item.subject = request_body.get('display_name')
|
||||
item.source_url = request_body.get('url')
|
||||
|
||||
|
@ -393,6 +396,9 @@ class CancelItemView(DetailView):
|
|||
cancellation_date__isnull=True)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not self.get_object().user_cancellable:
|
||||
messages.error(request, _('This item cannot be removed'))
|
||||
return HttpResponseRedirect(get_basket_url())
|
||||
try:
|
||||
self.get_object().notify_cancellation()
|
||||
except requests.exceptions.HTTPError:
|
||||
|
|
Loading…
Reference in New Issue