Merge branch 'aureplop/kfet-tests_remove-unused-views' into 'master'
kfet -- Remove unused view See merge request cof-geek/gestioCOF!312
This commit is contained in:
commit
ec29e6ef5c
2 changed files with 1 additions and 76 deletions
|
@ -24,8 +24,6 @@ urlpatterns = [
|
|||
# Account - Create
|
||||
url(r'^accounts/new$', views.account_create,
|
||||
name='kfet.account.create'),
|
||||
url(r'^accounts/new_special$', views.account_create_special,
|
||||
name='kfet.account.create_special'),
|
||||
url(r'^accounts/new/user/(?P<username>.+)$', views.account_create_ajax,
|
||||
name='kfet.account.create.fromuser'),
|
||||
url(r'^accounts/new/clipper/(?P<login_clipper>[\w-]+)/(?P<fullname>.*)$',
|
||||
|
|
|
@ -78,79 +78,6 @@ def account_is_validandfree_ajax(request):
|
|||
data = Account.is_validandfree(trigramme)
|
||||
return JsonResponse(data)
|
||||
|
||||
# Account - Create
|
||||
|
||||
@login_required
|
||||
@teamkfet_required
|
||||
def account_create_special(request):
|
||||
|
||||
# Enregistrement
|
||||
if request.method == "POST":
|
||||
trigramme_form = AccountTriForm(request.POST, initial={'balance':0})
|
||||
balance_form = AccountBalanceForm(request.POST)
|
||||
|
||||
# Peuplement des forms
|
||||
username = request.POST.get('username')
|
||||
login_clipper = request.POST.get('login_clipper')
|
||||
|
||||
forms = get_account_create_forms(
|
||||
request, username=username, login_clipper=login_clipper)
|
||||
|
||||
account_form = forms['account_form']
|
||||
cof_form = forms['cof_form']
|
||||
user_form = forms['user_form']
|
||||
|
||||
if all((user_form.is_valid(), cof_form.is_valid(),
|
||||
trigramme_form.is_valid(), account_form.is_valid(),
|
||||
balance_form.is_valid())):
|
||||
# Checking permission
|
||||
if not request.user.has_perm('kfet.special_add_account'):
|
||||
messages.error(request, 'Permission refusée')
|
||||
else:
|
||||
data = {}
|
||||
# Fill data for Account.save()
|
||||
put_cleaned_data_in_dict(data, user_form)
|
||||
put_cleaned_data_in_dict(data, cof_form)
|
||||
|
||||
try:
|
||||
account = trigramme_form.save(data = data)
|
||||
account_form = AccountNoTriForm(request.POST, instance=account)
|
||||
account_form.save()
|
||||
balance_form = AccountBalanceForm(request.POST, instance=account)
|
||||
balance_form.save()
|
||||
amount = balance_form.cleaned_data['balance']
|
||||
checkout = Checkout.objects.get(name='Initial')
|
||||
is_cof = account.is_cof
|
||||
opegroup = OperationGroup.objects.create(
|
||||
on_acc=account,
|
||||
checkout=checkout,
|
||||
amount = amount,
|
||||
is_cof = account.is_cof)
|
||||
ope = Operation.objects.create(
|
||||
group = opegroup,
|
||||
type = Operation.INITIAL,
|
||||
amount = amount)
|
||||
messages.success(request, 'Compte créé : %s' % account.trigramme)
|
||||
return redirect('kfet.account.create')
|
||||
except Account.UserHasAccount as e:
|
||||
messages.error(request, \
|
||||
"Cet utilisateur a déjà un compte K-Fêt : %s" % e.trigramme)
|
||||
else:
|
||||
initial = { 'trigramme': request.GET.get('trigramme', '') }
|
||||
trigramme_form = AccountTriForm(initial = initial)
|
||||
balance_form = AccountBalanceForm(initial = {'balance': 0})
|
||||
account_form = None
|
||||
cof_form = None
|
||||
user_form = None
|
||||
|
||||
return render(request, "kfet/account_create_special.html", {
|
||||
'trigramme_form': trigramme_form,
|
||||
'account_form': account_form,
|
||||
'cof_form': cof_form,
|
||||
'user_form': user_form,
|
||||
'balance_form': balance_form,
|
||||
})
|
||||
|
||||
|
||||
# Account - Create
|
||||
|
||||
|
@ -704,7 +631,7 @@ class ArticleList(ListView):
|
|||
)
|
||||
template_name = 'kfet/article.html'
|
||||
context_object_name = 'articles'
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
articles = context[self.context_object_name]
|
||||
|
|
Loading…
Reference in a new issue