Open-event-frontend: Tickets: Prevent deletion of tickets with sales

Created on 30 Sep 2020  路  22Comments  路  Source: fossasia/open-event-frontend

Formerly it was not possible to delete tickets that had sales already. Currently there is nothing preventing organizers from deleting those tickets types in the wizard step 1 though.

The feature should again work like that:

  • tickets that had sales should get an error message "Tickets that had sales cannot be deleted."
  • it should not be possible to reduce the number of tickets below the number of tickets that were sold. So, e.g. if 3 tickets were sold, the organizer should only be able to set the tickets to min. 3 (which means no more tickets would be available and the ticket would no longer show up on the public event page)

Compare: https://eventyay.com/events/a315169f/tickets

Screenshot from 2020-09-30 00-17-29

High bug codeheat

Most helpful comment

Keep the conversation on topic

All 22 comments

@mariobehling Can I work on this?

@BLasan go ahead!!

I'm working on this

I'm working on this

No it lead to duplicate work

Its been 4 days + no sign of work done. So @aman-jaglan can work on it.

Keep the conversation on topic

How can I publish an event it always ask me to confirm my email, but as I clicked on the email it sent it says NOT FOUND ?

Paste the confirmation link here

@iamareebjamal I am using the condition (ticket.attendees.toArray()).length > 0 for checking if it has sales, but in first attempt (ticket.attendees.toArray()).length; it always return 0, then return currect value.

This needs to be fixed on server, not frontend

ok

@iamareebjamal I am working on it on server-side, And I am not getting this -

if data.get('tickets', None): is always returning None in open-event-server/app/api/events.py

is there anything that need to be change in model?

Why will you get tickets in data? Override before_delete_object and check if ticket has any completed/placed orders

Added this in /open-event-server/app/api/tickets.py but not working -

class TicketDetail(ResourceDetail):
    """
    Ticket Resource
    """
    def before_delete_object(self, ticket, view_kwargs):
        """
        method to check for proper permissions for deleting
        :param order:
        :param view_kwargs:
        :return:
        """

        if not has_access('is_coorganizer', event_id=ticket.event_id):
            raise ForbiddenError({'source': ''}, 'Access Forbidden')
        elif (ticket.get('has_order_tickets')):
            raise ConflictError(
                {'source': ''}, 'You cannot delete a ticket that has sales.'

Where is the get function? This is not ember JS, it is python

def before_delete_object(self, ticket, view_kwargs):
        if not has_access('is_coorganizer', event_id=ticket.event_id):
            raise ForbiddenError({'source': ''}, 'Access Forbidden')
        elif (ticket.has_order_tickets):
            raise ConflictError(
                {'source': ''}, 'You cannot delete a ticket that has sales.'
            )

this is not working too. even if I am using if True: raise ForbiddenError({'source': ''}, 'Access Forbidden'), it made no effect.

It may be so that before_delete_object is not being called because ticket is soft deleted. Try before_update_object

ok

how it will keep track of deleted ticket, added this

if (ticket.has_order_tickets):
                raise UnprocessableEntityError(
                    {'event_id': ticket.event.id},
                    "Don't delete a ticket that has sales",

to before_update_object . But it checks if existing ticket has sales or not. How to check for deleted tickets?

I don't understand. I'll call you soon to understand

I can't find a way to pass this.totalOrder value from event.view.ticket->index.hbs to publish-bar.hbs can you help me on that ?

I don't think that is relevant to this issue

Was this page helpful?
0 / 5 - 0 ratings