Skip to content

Commit

Permalink
Revert "Feature tickets"
Browse files Browse the repository at this point in the history
  • Loading branch information
krestenlaust authored Oct 27, 2023
1 parent 1cb36ae commit 29cda30
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 200 deletions.
Empty file removed stregsystem.log
Empty file.
14 changes: 0 additions & 14 deletions stregsystem/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Room,
Sale,
MobilePayment,
Event,
NamedProduct,
)
from stregsystem.templatetags.stregsystem_extras import money
Expand Down Expand Up @@ -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)
Expand All @@ -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)
26 changes: 0 additions & 26 deletions stregsystem/migrations/0016_event.py

This file was deleted.

16 changes: 0 additions & 16 deletions stregsystem/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions stregsystem/templates/stregsystem/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
</th>
<th>
<a href="/{{room.id}}/user/{{member.id}}/pay">Indsæt penge</a>
</th>
<th>
<a href="/{{room.id}}/user/{{member.id}}/tickets">Mine billetter</a>
</th>
<th>
<a href="/{{room.id}}/user/{{member.id}}/rank">Rangliste</a>
Expand Down
34 changes: 0 additions & 34 deletions stregsystem/templates/stregsystem/menu_ticketsview.html

This file was deleted.

1 change: 0 additions & 1 deletion stregsystem/templates/stregsystem/menu_userinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,5 @@
</tr>
</table>


{% endblock %}

95 changes: 0 additions & 95 deletions stregsystem/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
PayTransaction,
Product,
Room,
Event,
Sale,
StregForbudError,
active_str,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion stregsystem/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
re_path(r'^(?P<room_id>\d+)/sale/\d+/\d+/$', lambda request, room_id: redirect('menu_index', room_id=room_id), name="menu_sale"),
re_path(r'^(?P<room_id>\d+)/user/(?P<member_id>\d+)/$', views.menu_userinfo, name="userinfo"),
re_path(r'^(?P<room_id>\d+)/user/(?P<member_id>\d+)/pay$', views.menu_userpay, name="userpay"),
re_path(r'^(?P<room_id>\d+)/user/(?P<member_id>\d+)/tickets$', views.menu_ticketsview, name="usertickets"),
re_path(r'^(?P<room_id>\d+)/user/(?P<member_id>\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"),
Expand Down
10 changes: 0 additions & 10 deletions stregsystem/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
Product,
Room,
Sale,
Event,
StregForbudError,
MobilePayment,
Category,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 29cda30

Please sign in to comment.