@@ -39,10 +39,8 @@ class ImportUploadView(LoginRequiredMixin, generic.edit.CreateView):
39
39
40
40
def form_valid (self , form ):
41
41
self .object = form .save ()
42
- account = form .cleaned_data ['account' ]
43
- importer = form .cleaned_data ['importer' ]
44
42
return HttpResponseRedirect (
45
- reverse ('import_process' , args = [self .object .pk , account . pk , importer ]))
43
+ reverse ('import_process' , args = [self .object .pk ]))
46
44
47
45
48
46
class ImportProcessView (LoginRequiredMixin , generic .TemplateView ):
@@ -51,7 +49,7 @@ class ImportProcessView(LoginRequiredMixin, generic.TemplateView):
51
49
def get_context_data (self , ** kwargs ):
52
50
context = super (ImportProcessView , self ).get_context_data (** kwargs )
53
51
file = models .ImportFile .objects .get (uuid = self .kwargs ['uuid' ])
54
- importer = self . kwargs [ ' importer' ]
52
+ importer = file . importer
55
53
iban_accounts = dict ()
56
54
names = dict ()
57
55
for a in models .Account .objects .all ():
@@ -102,7 +100,7 @@ def get_context_data(self, **kwargs):
102
100
103
101
def post (self , request , * args , ** kwargs ):
104
102
file = models .ImportFile .objects .get (uuid = self .kwargs ['uuid' ])
105
- importer = self . kwargs [ ' importer' ]
103
+ importer = file . importer
106
104
data = importers .IMPORTERS [importer ].import_transactions (file .file .path )
107
105
for i in range (len (data )):
108
106
title = request .POST .get ('title-{}' .format (i ), '' )
@@ -127,19 +125,19 @@ def post(self, request, *args, **kwargs):
127
125
if account .account_type == models .Account .AccountType .PERSONAL :
128
126
transaction .transaction_type = models .Transaction .TRANSFER
129
127
if amount < 0 :
130
- transaction .src_id = self . kwargs [ 'account' ]
128
+ transaction .src_id = file . account_id
131
129
transaction .dst = account
132
130
else :
133
131
transaction .src = account
134
- transaction .dst_id = self . kwargs [ 'account' ]
132
+ transaction .dst_id = file . account_id
135
133
elif account .account_type == models .Account .AccountType .FOREIGN :
136
134
if amount < 0 :
137
135
transaction .transaction_type = models .Transaction .WITHDRAW
138
- transaction .src_id = self . kwargs [ 'account' ]
136
+ transaction .src_id = file . account_id
139
137
transaction .dst = account
140
138
else :
141
139
transaction .transaction_type = models .Transaction .DEPOSIT
142
- transaction .dst_id = self . kwargs [ 'account' ]
140
+ transaction .dst_id = file . account_id
143
141
transaction .src = account
144
142
transaction .title = title
145
143
transaction .date = date
@@ -154,7 +152,7 @@ def post(self, request, *args, **kwargs):
154
152
amount = amount ,
155
153
date = book_date ,
156
154
transaction = transaction ,
157
- account_id = self . kwargs [ 'account' ] ,
155
+ account_id = file . account_id ,
158
156
opposing_account = account
159
157
)
160
158
models .Split .objects .create (
@@ -163,7 +161,7 @@ def post(self, request, *args, **kwargs):
163
161
date = date ,
164
162
transaction = transaction ,
165
163
account = account ,
166
- opposing_account_id = self . kwargs [ 'account' ]
164
+ opposing_account_id = file . account_id
167
165
)
168
166
return HttpResponseRedirect ('/' )
169
167
0 commit comments