def get(self, request, start, end):
        start = datetime.strptime(start, '%Y-%m-%d')
        end = datetime.strptime(end, '%Y-%m-%d')
        transactions = PaymentAdapter.get_report_data(start, end)

        return render(request, self.template_name,
                      {'transactions': transactions, 'start': start, 'end': end})
    def view_report(self, request, start, end):
        start = datetime.strptime(start, '%Y-%m-%d')
        end = datetime.strptime(end, '%Y-%m-%d')
        transactions = PaymentAdapter.get_report_data(start, end)
        report = Report()
        PrinterAdapter.print_report(report)
        messages.add_message(request, messages.INFO, 'Печать отчёта запланирована.')

        return render(request, self.template_name,
                      {'transactions': transactions, 'start': start, 'end': end})
    def subscribe_to_user(self, request, username, plan_id):
        subscribee = User.objects.get(username=username)
        plan = Plan.objects.get(id=plan_id)
        customer = self.request.user

        payment = PaymentAdapter.create_payment(plan, customer, subscribee)
        transaction = payment.process()
        subscription = Subscription(plan=plan, customer=customer, subscribee=subscribee, transaction=transaction)
        subscription.save()

        return render(request, self.details_template_name, {'payment': payment, 'subscription': subscription})
    def get(self, request, username, plan_id):
        form = self.form_class()

        return render(request, PaymentAdapter.get_payment_page(),
                      {'form': form, 'plan_id': plan_id})