|
@@ -17,6 +17,9 @@ from django.core.urlresolvers import reverse
|
|
|
import autocomplete_light
|
|
|
from functools import update_wrapper
|
|
|
|
|
|
+from .forms import WizardImportPaymentCSV
|
|
|
+from .import_payments_from_csv import process
|
|
|
+
|
|
|
class InvoiceDetailInlineForm(forms.ModelForm):
|
|
|
class Meta:
|
|
|
model = InvoiceDetail
|
|
@@ -251,33 +254,41 @@ class PaymentAdmin(admin.ModelAdmin):
|
|
|
|
|
|
info = self.model._meta.app_label, self.model._meta.model_name
|
|
|
|
|
|
- print(urls)
|
|
|
-
|
|
|
my_urls = [
|
|
|
url(r'wizard_import_payment_csv/$', wrap(self.wizard_import_payment_csv), name='wizard_import_payment_csv'),
|
|
|
]
|
|
|
|
|
|
- print(my_urls)
|
|
|
-
|
|
|
return my_urls + urls
|
|
|
|
|
|
|
|
|
def wizard_import_payment_csv(self, request):
|
|
|
template = "admin/billing/payment/wizard_import_payment_csv.html"
|
|
|
|
|
|
- from .forms import WizardImportPaymentCSV
|
|
|
-
|
|
|
if request.method == 'POST':
|
|
|
form = WizardImportPaymentCSV(request.POST, request.FILES)
|
|
|
if form.is_valid():
|
|
|
- form.analyze_CSV()
|
|
|
- return HttpResponseRedirect('/success/url/')
|
|
|
+
|
|
|
+ # Analyze
|
|
|
+ new_payments = process(request.FILES["csv_file"])
|
|
|
+
|
|
|
+ # If the user didn't ask for commit yet
|
|
|
+ # display the result of the analyze (i.e. the matching)
|
|
|
+ if "commit" not in request.POST:
|
|
|
+ return render(request, template, {
|
|
|
+ 'adminform': form,
|
|
|
+ 'opts': self.model._meta,
|
|
|
+ 'new_payments': new_payments
|
|
|
+ })
|
|
|
+ else:
|
|
|
+ import pdb; pdb.set_trace()
|
|
|
+ # To be implemented
|
|
|
else:
|
|
|
form = WizardImportPaymentCSV()
|
|
|
|
|
|
return render(request, template, {
|
|
|
'adminform': form,
|
|
|
- }, context_instance=RequestContext(request))
|
|
|
+ 'opts': self.model._meta
|
|
|
+ })
|
|
|
|
|
|
|
|
|
class MembershipFeeAdmin(admin.ModelAdmin):
|