@@ 724-750 (lines=27) @@ | ||
721 | } |
|
722 | ||
723 | ||
724 | @blueprint.post('/<uuid:article_id>/actions/ticket_bundles_creation') |
|
725 | @permission_required('shop_article.update') |
|
726 | def action_create_for_ticket_bundles_creation(article_id): |
|
727 | """Register a ticket bundles creation action for the article.""" |
|
728 | article = _get_article_or_404(article_id) |
|
729 | ||
730 | shop = shop_service.get_shop(article.shop_id) |
|
731 | brand = brand_service.get_brand(shop.brand_id) |
|
732 | ||
733 | form = RegisterTicketBundlesCreationActionForm(request.form) |
|
734 | form.set_category_choices(brand.id) |
|
735 | ||
736 | if not form.validate(): |
|
737 | return action_create_form_for_ticket_bundles_creation(article_id, form) |
|
738 | ||
739 | category_id = form.category_id.data |
|
740 | category = ticket_category_service.get_category(category_id) |
|
741 | ||
742 | ticket_quantity = form.ticket_quantity.data |
|
743 | ||
744 | action_registry_service.register_ticket_bundles_creation( |
|
745 | article.item_number, category.id, ticket_quantity |
|
746 | ) |
|
747 | ||
748 | flash_success(gettext('Action has been added.')) |
|
749 | ||
750 | return redirect_to('.view', article_id=article.id) |
|
751 | ||
752 | ||
753 | @blueprint.delete('/actions/<uuid:action_id>') |
|
@@ 670-694 (lines=25) @@ | ||
667 | } |
|
668 | ||
669 | ||
670 | @blueprint.post('/<uuid:article_id>/actions/tickets_creation') |
|
671 | @permission_required('shop_article.update') |
|
672 | def action_create_for_tickets_creation(article_id): |
|
673 | """Register a tickets creation action for the article.""" |
|
674 | article = _get_article_or_404(article_id) |
|
675 | ||
676 | shop = shop_service.get_shop(article.shop_id) |
|
677 | brand = brand_service.get_brand(shop.brand_id) |
|
678 | ||
679 | form = RegisterTicketsCreationActionForm(request.form) |
|
680 | form.set_category_choices(brand.id) |
|
681 | ||
682 | if not form.validate(): |
|
683 | return action_create_form_for_tickets_creation(article_id, form) |
|
684 | ||
685 | category_id = form.category_id.data |
|
686 | category = ticket_category_service.get_category(category_id) |
|
687 | ||
688 | action_registry_service.register_tickets_creation( |
|
689 | article.item_number, category.id |
|
690 | ) |
|
691 | ||
692 | flash_success(gettext('Action has been added.')) |
|
693 | ||
694 | return redirect_to('.view', article_id=article.id) |
|
695 | ||
696 | ||
697 | @blueprint.get('/<uuid:article_id>/actions/ticket_bundles_creation/create') |