コード例 #1
0
 def post(self, request, *args, **kwargs):
     profile = Profile.objects.get_or_create(user=self.request.user)
     profile = profile[0]
     links = upload_file(self.request, 'attached_file', ['image/png', 'image/jpeg'])
     profile.image_url = links['dropbox']
     profile.save()
     return HttpResponseRedirect(reverse_lazy('accounts:user-profile'))
コード例 #2
0
 def form_valid(self, form):
     entry = form.save(commit=False)
     links = upload_file(self.request, 'attached_file')
     entry.attached_file_url = links['dropbox']
     entry.user = self.request.user
     entry.amount = get_entry_amount(entry.amount, entry.amount.currency,
                                     'GASTO')
     entry.balance = get_new_balance(
         entry.amount,
         entry.amount.currency,
     )
     entry.entry_type = EntryType.objects.get(title='Gasto')
     entry.save()
     response = super(EntryCreateDebt, self).form_valid(form)
     return response
コード例 #3
0
 def form_valid(self, form):
     user_entry = form.save(commit=False)
     links = upload_file(self.request, 'attached_file')
     user_entry.attached_file_url = links['dropbox']
     user_entry.target_user = User.objects.get(
         pk=self.kwargs.get('user_target_id'))
     user_entry.user = self.request.user
     user_entry.amount = get_user_entry_amount(user_entry.amount,
                                               user_entry.amount.currency,
                                               'PAGO')
     user_entry.balance = get_new_user_balance(
         user_entry.amount,
         user_entry.amount.currency,
         self.kwargs.get('user_target_id'),
     )
     user_entry.entry_type = EntryType.objects.get(title='Pago')
     user_entry.save()
     response = super(UserEntryCreatePayment, self).form_valid(form)
     return response