コード例 #1
0
ファイル: views.py プロジェクト: ssteinerx/foodnetwork
def invoice_selection(request):
    init = {"order_date": next_delivery_date(),}
    customer = get_customer(request)
    if not customer:
        return render_to_response('account/no_permissions.html')
    pp_settings = PayPalSettings.objects.all()
    pay_now = ""
    if pp_settings.count():
        pay_now = "- click here to pay now"
    if request.method == "POST":
        drform = DateRangeSelectionForm(request.POST)  
        if drform.is_valid():
            dsdata = drform.cleaned_data
            from_date = dsdata['from_date'].strftime('%Y_%m_%d')
            to_date = dsdata['to_date'].strftime('%Y_%m_%d')
            return HttpResponseRedirect('/%s/%s/%s/%s/'
               % ('customer/invoices', customer.id, from_date, to_date))
    else:
        unpaid_invoices = Order.objects.filter(
            customer=customer,
            state="Filled")
        to_date = datetime.date.today()
        from_date = to_date - datetime.timedelta(weeks=16)
        init = {
            'from_date': from_date,
            'to_date': to_date,
        }
        drform = DateRangeSelectionForm(initial=init)
    return render_to_response('customer/invoice_selection.html', {
        'date_range_form': drform,
        'unpaid_invoices': unpaid_invoices,
    }, context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: ssteinerx/foodnetwork
def history_selection(request):
    fn = food_network()
    customer = get_customer(request)
    if not customer:
        return render_to_response('account/no_permissions.html')
    if request.method == "POST":
        drform = DateRangeSelectionForm(request.POST)  
        if drform.is_valid():
            dsdata = drform.cleaned_data
            from_date = dsdata['from_date'].strftime('%Y_%m_%d')
            to_date = dsdata['to_date'].strftime('%Y_%m_%d')
            return HttpResponseRedirect('/%s/%s/%s/%s/'
               % ('customer/history', customer.id, from_date, to_date))
    else:
        to_date = datetime.date.today()
        from_date = to_date - datetime.timedelta(weeks=16)
        init = {
            'from_date': from_date,
            'to_date': to_date,
        }
        drform = DateRangeSelectionForm(initial=init)
    return render_to_response('customer/history_selection.html', 
        {'customer': customer,
         'food_network': fn,
        'date_range_form': drform,
         }, context_instance=RequestContext(request))
コード例 #3
0
ファイル: views.py プロジェクト: bhaugen/django-fad
def invoice_selection(request):
    init = {"order_date": current_week(),}
    customer = request.user.parties.all()[0].party
    if request.method == "POST":
        drform = DateRangeSelectionForm(request.POST)  
        if drform.is_valid():
            dsdata = drform.cleaned_data
            from_date = dsdata['from_date'].strftime('%Y_%m_%d')
            to_date = dsdata['to_date'].strftime('%Y_%m_%d')
            return HttpResponseRedirect('/%s/%s/%s/%s/'
               % ('customer/invoices', customer.id, from_date, to_date))
    else:
        unpaid_invoices = Order.objects.filter(
            customer=customer,
            state="Delivered")
        to_date = datetime.date.today()
        from_date = to_date - datetime.timedelta(weeks=16)
        init = {
            'from_date': from_date,
            'to_date': to_date,
        }
        drform = DateRangeSelectionForm(initial=init)
    return render_to_response('customer/invoice_selection.html', {
        'date_range_form': drform,
        'unpaid_invoices': unpaid_invoices,
    })
コード例 #4
0
ファイル: views.py プロジェクト: bhaugen/django-fad
def history_selection(request):
    food_network = FoodNetwork.objects.get(pk=1)
    customer = request.user.parties.all()[0].party
    if request.method == "POST":
        drform = DateRangeSelectionForm(request.POST)  
        if drform.is_valid():
            dsdata = drform.cleaned_data
            from_date = dsdata['from_date'].strftime('%Y_%m_%d')
            to_date = dsdata['to_date'].strftime('%Y_%m_%d')
            return HttpResponseRedirect('/%s/%s/%s/%s/'
               % ('customer/history', customer.id, from_date, to_date))
    else:
        to_date = datetime.date.today()
        from_date = to_date - datetime.timedelta(weeks=16)
        init = {
            'from_date': from_date,
            'to_date': to_date,
        }
        drform = DateRangeSelectionForm(initial=init)
    return render_to_response('customer/history_selection.html', 
        {'customer': customer,
         'food_network': food_network,
        'date_range_form': drform,
         }, context_instance=RequestContext(request))
コード例 #5
0
ファイル: views.py プロジェクト: ssteinerx/foodnetwork
def plan_selection(request):
    # import pdb; pdb.set_trace()
    from_date = datetime.date.today()
    # force from_date to Monday, to_date to Sunday
    from_date = from_date - datetime.timedelta(days=datetime.date.weekday(from_date))
    to_date = from_date + datetime.timedelta(weeks=16)
    to_date = to_date - datetime.timedelta(days=datetime.date.weekday(to_date) + 1)
    to_date = to_date + datetime.timedelta(days=7)
    plan_init = {"plan_from_date": from_date, "plan_to_date": to_date, "list_type": "M"}
    init = {"from_date": from_date, "to_date": to_date}
    member = get_producer(request)
    member_has_plans = False
    plans = ProductPlan.objects.filter(member=member)
    if plans.count():
        member_has_plans = True

    if request.method == "POST":
        if request.POST.get("submit-supply-demand"):
            sdform = DateRangeSelectionForm(prefix="sd", data=request.POST)
            if sdform.is_valid():
                data = sdform.cleaned_data
                from_date = data["from_date"].strftime("%Y_%m_%d")
                to_date = data["to_date"].strftime("%Y_%m_%d")
                return HttpResponseRedirect("/%s/%s/%s/" % ("producer/supplydemand", from_date, to_date))
            else:
                psform = PlanSelectionForm(initial=plan_init)
                income_form = DateRangeSelectionForm(prefix="inc", initial=init)

        elif request.POST.get("submit-income"):
            income_form = DateRangeSelectionForm(prefix="inc", data=request.POST)
            if income_form.is_valid():
                data = income_form.cleaned_data
                from_date = data["from_date"].strftime("%Y_%m_%d")
                to_date = data["to_date"].strftime("%Y_%m_%d")
                return HttpResponseRedirect("/%s/%s/%s/" % ("producer/income", from_date, to_date))
            else:
                psform = PlanSelectionForm(initial=plan_init)
                sdform = DateRangeSelectionForm(prefix="sd", initial=init)

        else:
            psform = PlanSelectionForm(request.POST)
            if psform.is_valid():
                psdata = psform.cleaned_data
                from_date = psdata["plan_from_date"].strftime("%Y_%m_%d")
                to_date = psdata["plan_to_date"].strftime("%Y_%m_%d")
                list_type = psdata["list_type"]
                return HttpResponseRedirect(
                    "/%s/%s/%s/%s/%s/" % ("producer/planningtable", member.id, list_type, from_date, to_date)
                )
            else:
                sdform = DateRangeSelectionForm(prefix="sd", initial=init)
                income_form = DateRangeSelectionForm(prefix="inc", initial=init)

    else:
        psform = PlanSelectionForm(initial=plan_init)
        sdform = DateRangeSelectionForm(prefix="sd", initial=init)
        income_form = DateRangeSelectionForm(prefix="inc", initial=init)
    return render_to_response(
        "producer/plan_selection.html",
        {"plan_form": psform, "sdform": sdform, "income_form": income_form, "member_has_plans": member_has_plans},
        context_instance=RequestContext(request),
    )
コード例 #6
0
def plan_selection(request):
    #import pdb; pdb.set_trace()
    from_date = datetime.date.today()
    # force from_date to Monday, to_date to Sunday
    from_date = from_date - datetime.timedelta(
        days=datetime.date.weekday(from_date))
    to_date = from_date + datetime.timedelta(weeks=16)
    to_date = to_date - datetime.timedelta(
        days=datetime.date.weekday(to_date) + 1)
    to_date = to_date + datetime.timedelta(days=7)
    plan_init = {
        'plan_from_date': from_date,
        'plan_to_date': to_date,
        'list_type': 'M',
    }
    init = {
        'from_date': from_date,
        'to_date': to_date,
    }
    member = get_producer(request)
    member_has_plans = False
    plans = ProductPlan.objects.filter(member=member)
    if plans.count():
        member_has_plans = True

    if request.method == "POST":
        if request.POST.get('submit-supply-demand'):
            sdform = DateRangeSelectionForm(prefix='sd', data=request.POST)
            if sdform.is_valid():
                data = sdform.cleaned_data
                from_date = data['from_date'].strftime('%Y_%m_%d')
                to_date = data['to_date'].strftime('%Y_%m_%d')
                return HttpResponseRedirect(
                    '/%s/%s/%s/' %
                    ('producer/supplydemand', from_date, to_date))
            else:
                psform = PlanSelectionForm(initial=plan_init)
                income_form = DateRangeSelectionForm(prefix='inc',
                                                     initial=init)

        elif request.POST.get('submit-income'):
            income_form = DateRangeSelectionForm(prefix='inc',
                                                 data=request.POST)
            if income_form.is_valid():
                data = income_form.cleaned_data
                from_date = data['from_date'].strftime('%Y_%m_%d')
                to_date = data['to_date'].strftime('%Y_%m_%d')
                return HttpResponseRedirect(
                    '/%s/%s/%s/' % ('producer/income', from_date, to_date))
            else:
                psform = PlanSelectionForm(initial=plan_init)
                sdform = DateRangeSelectionForm(prefix='sd', initial=init)

        else:
            psform = PlanSelectionForm(request.POST)
            if psform.is_valid():
                psdata = psform.cleaned_data
                from_date = psdata['plan_from_date'].strftime('%Y_%m_%d')
                to_date = psdata['plan_to_date'].strftime('%Y_%m_%d')
                list_type = psdata['list_type']
                return HttpResponseRedirect(
                    '/%s/%s/%s/%s/%s/' % ('producer/planningtable', member.id,
                                          list_type, from_date, to_date))
            else:
                sdform = DateRangeSelectionForm(prefix='sd', initial=init)
                income_form = DateRangeSelectionForm(prefix='inc',
                                                     initial=init)

    else:
        psform = PlanSelectionForm(initial=plan_init)
        sdform = DateRangeSelectionForm(prefix='sd', initial=init)
        income_form = DateRangeSelectionForm(prefix='inc', initial=init)
    return render_to_response('producer/plan_selection.html', {
        'plan_form': psform,
        'sdform': sdform,
        'income_form': income_form,
        'member_has_plans': member_has_plans,
    },
                              context_instance=RequestContext(request))