diff --git a/stregsystem.log b/stregsystem.log deleted file mode 100644 index e69de29b..00000000 diff --git a/stregsystem/admin.py b/stregsystem/admin.py index 901ece63..36348820 100644 --- a/stregsystem/admin.py +++ b/stregsystem/admin.py @@ -14,7 +14,6 @@ Room, Sale, MobilePayment, - Event, NamedProduct, ) from stregsystem.templatetags.stregsystem_extras import money @@ -342,18 +341,6 @@ def has_delete_permission(self, request, obj=None): return False -class EventEntryAdmin(admin.ModelAdmin): - search_fields = ('name', 'id') - list_display = ( - 'activated', - 'id', - 'name', - ) - - def activated(self, event): - return event.is_active() - - admin.site.register(LogEntry, LogEntryAdmin) admin.site.register(Sale, SaleAdmin) admin.site.register(Member, MemberAdmin) @@ -364,4 +351,3 @@ def activated(self, event): admin.site.register(Category, CategoryAdmin) admin.site.register(Room) admin.site.register(MobilePayment, MobilePaymentAdmin) -admin.site.register(Event, EventEntryAdmin) diff --git a/stregsystem/migrations/0016_event.py b/stregsystem/migrations/0016_event.py deleted file mode 100644 index 7b4e18e4..00000000 --- a/stregsystem/migrations/0016_event.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 2.2.24 on 2022-04-12 17:47 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('stregsystem', '0015_product_caffeine_content_mg'), - ] - - operations = [ - migrations.CreateModel( - name='Event', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=32)), - ('active', models.BooleanField()), - ('time', models.DateTimeField()), - ('ticket_start_threshold', models.DateTimeField()), - ('ticket_end_threshold', models.DateTimeField()), - ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stregsystem.Product')), - ], - ), - ] diff --git a/stregsystem/models.py b/stregsystem/models.py index b6d9835e..afc9d428 100644 --- a/stregsystem/models.py +++ b/stregsystem/models.py @@ -617,22 +617,6 @@ def __str__(self): return self.product.name + ": " + money(self.price) + " (" + str(self.changed_on) + ")" -# A model to link certain products to events, to facilitate showing of active tickets -class Event(models.Model): - name = models.CharField(max_length=32) - active = models.BooleanField() - product = models.ForeignKey(Product, on_delete=models.CASCADE) - time = models.DateTimeField(null=False, blank=False) - ticket_start_threshold = models.DateTimeField(null=False, blank=False) - ticket_end_threshold = models.DateTimeField(null=False, blank=False) - - def is_active(self): - is_after_start = self.ticket_start_threshold <= timezone.now() - is_before_end = self.ticket_end_threshold >= timezone.now() - - return self.active and is_after_start and is_before_end - - class Sale(models.Model): member = models.ForeignKey(Member, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE) diff --git a/stregsystem/templates/stregsystem/menu.html b/stregsystem/templates/stregsystem/menu.html index 8180199e..a534f418 100644 --- a/stregsystem/templates/stregsystem/menu.html +++ b/stregsystem/templates/stregsystem/menu.html @@ -25,9 +25,6 @@ Indsæt penge - - - Mine billetter Rangliste diff --git a/stregsystem/templates/stregsystem/menu_ticketsview.html b/stregsystem/templates/stregsystem/menu_ticketsview.html deleted file mode 100644 index 6d513caf..00000000 --- a/stregsystem/templates/stregsystem/menu_ticketsview.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "stregsystem/base.html" %} - -{% load stregsystem_extras %} - -{% block title %}Treoens stregsystem : Brugerinfo {% endblock %} - -{% block content %} -

{{member.firstname}} {{member.lastname}} ({{member.email}})

- -

Tilbage til produktmenu

- -
-Aktive billeter - - - - - - - -{% autoescape off %} -{% for event in bought_events_list %} - - - - - - -{% endfor %} -{% endautoescape %} -
EventProduktPrisStart Tidspunkt
{{event.name}}{{event.product.name}}{{event.product.price|money}}{{event.time}}
-
- -{% endblock %} \ No newline at end of file diff --git a/stregsystem/templates/stregsystem/menu_userinfo.html b/stregsystem/templates/stregsystem/menu_userinfo.html index 64cf56f6..bca4c060 100644 --- a/stregsystem/templates/stregsystem/menu_userinfo.html +++ b/stregsystem/templates/stregsystem/menu_userinfo.html @@ -90,6 +90,5 @@ - {% endblock %} diff --git a/stregsystem/tests.py b/stregsystem/tests.py index a8a03619..8dfe16cf 100644 --- a/stregsystem/tests.py +++ b/stregsystem/tests.py @@ -33,7 +33,6 @@ PayTransaction, Product, Room, - Event, Sale, StregForbudError, active_str, @@ -756,100 +755,6 @@ def test_is_active_deactive_in_stock(self): self.assertFalse(product.is_active()) -class EventTests(TestCase): - def setUp(self): - self.jeff = Member.objects.create( - username="Jeff", - ) - - def test_is_active_active_not_expired(self): - product = Product.objects.create( - active=True, - price=100, - ) - event = Event.objects.create( - name="testEvent", - active=True, - product=product, - time=timezone.now() + datetime.timedelta(hours=1), - ticket_start_threshold=timezone.now() - datetime.timedelta(hours=1), - ticket_end_threshold=timezone.now() + datetime.timedelta(hours=1), - ) - - self.assertTrue(event.is_active()) - - def test_is_active_active_expired_after(self): - product = Product.objects.create( - active=True, - price=100, - ) - event = Event.objects.create( - name="testEvent", - active=True, - product=product, - time=timezone.now() + datetime.timedelta(hours=1), - ticket_start_threshold=timezone.now() - datetime.timedelta(hours=10), - ticket_end_threshold=timezone.now() - datetime.timedelta(hours=1), - ) - - self.assertFalse(event.is_active()) - - def test_is_active_active_before_active(self): - product = Product.objects.create( - active=True, - price=100, - ) - event = Event.objects.create( - name="testEvent", - active=True, - product=product, - time=timezone.now() + datetime.timedelta(hours=1), - ticket_start_threshold=timezone.now() + datetime.timedelta(hours=2), - ticket_end_threshold=timezone.now() + datetime.timedelta(hours=5), - ) - - self.assertFalse(event.is_active()) - - def test_is_active_inactive(self): - product = Product.objects.create( - active=True, - price=100, - ) - event = Event.objects.create( - name="testEvent", - active=False, - product=product, - time=timezone.now() + datetime.timedelta(hours=1), - ticket_start_threshold=timezone.now() - datetime.timedelta(hours=10), - ticket_end_threshold=timezone.now() - datetime.timedelta(hours=1), - ) - - self.assertFalse(event.is_active()) - - def test_is_active_inactive_expired(self): - product = Product.objects.create( - active=False, price=100, deactivate_date=(timezone.now() - datetime.timedelta(hours=1)) - ) - - self.assertFalse(product.is_active()) - - def test_is_active_deactive_out_of_stock(self): - product = Product.objects.create( - active=False, price=100, quantity=1, start_date=datetime.date(year=2017, month=12, day=1) - ) - product.sale_set.create(price=100, member=self.jeff) - - self.assertFalse(product.is_active()) - - def test_is_active_deactive_in_stock(self): - product = Product.objects.create( - active=False, price=100, quantity=2, start_date=datetime.date(year=2017, month=12, day=1) - ) - product.sale_set.create(price=100, member=self.jeff) - - self.assertFalse(product.is_active()) - - class SaleTests(TestCase): def setUp(self): self.member = Member.objects.create(username="jon", balance=100) diff --git a/stregsystem/urls.py b/stregsystem/urls.py index b9740913..382e3254 100644 --- a/stregsystem/urls.py +++ b/stregsystem/urls.py @@ -28,7 +28,6 @@ re_path(r'^(?P\d+)/sale/\d+/\d+/$', lambda request, room_id: redirect('menu_index', room_id=room_id), name="menu_sale"), re_path(r'^(?P\d+)/user/(?P\d+)/$', views.menu_userinfo, name="userinfo"), re_path(r'^(?P\d+)/user/(?P\d+)/pay$', views.menu_userpay, name="userpay"), - re_path(r'^(?P\d+)/user/(?P\d+)/tickets$', views.menu_ticketsview, name="usertickets"), re_path(r'^(?P\d+)/user/(?P\d+)/rank$', views.menu_userrank, name="userrank"), re_path(r'^api/member/payment/qr$', views.qr_payment, name="payment_qr"), re_path(r'^api/member/active$', views.check_user_active, name="active_member"), diff --git a/stregsystem/views.py b/stregsystem/views.py index 304defaa..e066b8ca 100644 --- a/stregsystem/views.py +++ b/stregsystem/views.py @@ -33,7 +33,6 @@ Product, Room, Sale, - Event, StregForbudError, MobilePayment, Category, @@ -243,15 +242,6 @@ def menu_userinfo(request, room_id, member_id): return render(request, 'stregsystem/menu_userinfo.html', locals()) -# Used to see active tickets -def menu_ticketsview(request, room_id, member_id): - room = Room.objects.get(pk=room_id) - member = Member.objects.get(pk=member_id, active=True) - bought_events_list = Event.objects.filter(product__in=member.sale_set.values('product')) - - return render(request, 'stregsystem/menu_ticketsview.html', locals()) - - def menu_userpay(request, room_id, member_id): room = Room.objects.get(pk=room_id) member = Member.objects.get(pk=member_id, active=True)