Code Duplication    Length = 25-27 lines in 2 locations

byceps/blueprints/admin/shop/article/views.py 2 locations

@@ 805-831 (lines=27) @@
802
    }
803
804
805
@blueprint.post('/<uuid:article_id>/actions/ticket_bundles_creation')
806
@permission_required('shop_article.update')
807
def action_create_for_ticket_bundles_creation(article_id):
808
    """Register a ticket bundles creation action for the article."""
809
    article = _get_article_or_404(article_id)
810
811
    shop = shop_service.get_shop(article.shop_id)
812
    brand = brand_service.get_brand(shop.brand_id)
813
814
    form = RegisterTicketBundlesCreationActionForm(request.form)
815
    form.set_category_choices(brand.id)
816
817
    if not form.validate():
818
        return action_create_form_for_ticket_bundles_creation(article_id, form)
819
820
    category_id = form.category_id.data
821
    category = ticket_category_service.get_category(category_id)
822
823
    ticket_quantity = form.ticket_quantity.data
824
825
    order_action_registry_service.register_ticket_bundles_creation(
826
        article.id, category.id, ticket_quantity
827
    )
828
829
    flash_success(gettext('Action has been added.'))
830
831
    return redirect_to('.view', article_id=article.id)
832
833
834
@blueprint.delete('/actions/<uuid:action_id>')
@@ 751-775 (lines=25) @@
748
    }
749
750
751
@blueprint.post('/<uuid:article_id>/actions/tickets_creation')
752
@permission_required('shop_article.update')
753
def action_create_for_tickets_creation(article_id):
754
    """Register a tickets creation action for the article."""
755
    article = _get_article_or_404(article_id)
756
757
    shop = shop_service.get_shop(article.shop_id)
758
    brand = brand_service.get_brand(shop.brand_id)
759
760
    form = RegisterTicketsCreationActionForm(request.form)
761
    form.set_category_choices(brand.id)
762
763
    if not form.validate():
764
        return action_create_form_for_tickets_creation(article_id, form)
765
766
    category_id = form.category_id.data
767
    category = ticket_category_service.get_category(category_id)
768
769
    order_action_registry_service.register_tickets_creation(
770
        article.id, category.id
771
    )
772
773
    flash_success(gettext('Action has been added.'))
774
775
    return redirect_to('.view', article_id=article.id)
776
777
778
@blueprint.get('/<uuid:article_id>/actions/ticket_bundles_creation/create')