mirror of https://gitlab.crans.org/bde/nk20
front improvement on alias page
This commit is contained in:
parent
35d5bcdf0f
commit
b7e68722aa
|
@ -186,7 +186,6 @@ class AliasView(LoginRequiredMixin,FormMixin,DetailView):
|
||||||
alias = form.save(commit=False)
|
alias = form.save(commit=False)
|
||||||
alias.note = self.object.note
|
alias.note = self.object.note
|
||||||
alias.save()
|
alias.save()
|
||||||
alias.note.save()
|
|
||||||
print(alias,alias.pk)
|
print(alias,alias.pk)
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
@ -202,7 +201,7 @@ class DeleteAliasView(LoginRequiredMixin, DeleteView):
|
||||||
messages.error(self.request,str(e))
|
messages.error(self.request,str(e))
|
||||||
else:
|
else:
|
||||||
messages.success(self.request,_("Alias successfully deleted"))
|
messages.success(self.request,_("Alias successfully deleted"))
|
||||||
return HttpResponseRedirect(get_success_url)
|
return HttpResponseRedirect(self.get_success_url())
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
print(self.request)
|
print(self.request)
|
||||||
|
|
|
@ -12,8 +12,12 @@ class AliasForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Alias
|
model = Alias
|
||||||
fields = ("name",)
|
fields = ("name",)
|
||||||
|
def __init__(self,*args,**kwargs):
|
||||||
|
super().__init__(*args,**kwargs)
|
||||||
|
self.fields["name"].label = False
|
||||||
|
self.fields["name"].widget.attrs={"placeholder":_('New Alias')}
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateForm(forms.ModelForm):
|
class TransactionTemplateForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TransactionTemplate
|
model = TransactionTemplate
|
||||||
|
|
|
@ -227,12 +227,13 @@ class Alias(models.Model):
|
||||||
try:
|
try:
|
||||||
sim_alias = Alias.objects.get(normalized_name=normalized_name)
|
sim_alias = Alias.objects.get(normalized_name=normalized_name)
|
||||||
if self != sim_alias:
|
if self != sim_alias:
|
||||||
raise ValidationError(_('An alias with a similar name already exists:'),
|
raise ValidationError(_('An alias with a similar name already exists: {} '.format(sim_alias)),
|
||||||
code="same_alias"
|
code="same_alias"
|
||||||
)
|
)
|
||||||
except Alias.DoesNotExist:
|
except Alias.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
self.normalized_name = normalized_name
|
||||||
|
|
||||||
def delete(self, using=None, keep_parents=False):
|
def delete(self, using=None, keep_parents=False):
|
||||||
if self.name == str(self.note):
|
if self.name == str(self.note):
|
||||||
raise ValidationError(_("You can't delete your main alias."),
|
raise ValidationError(_("You can't delete your main alias."),
|
||||||
|
|
|
@ -32,8 +32,14 @@ class AliasTable(tables.Table):
|
||||||
'table table condensed table-striped table-hover'
|
'table table condensed table-striped table-hover'
|
||||||
}
|
}
|
||||||
model = Alias
|
model = Alias
|
||||||
fields = ('name','pk')
|
fields =('name',)
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
|
||||||
delete = tables.LinkColumn('member:user_alias_delete', args=[A('pk')], attrs={
|
show_header = False
|
||||||
'a': {'class': 'btn btn-danger'} },text='delete',accessor='pk')
|
name = tables.Column(attrs={'td':{'class':'text-center'}})
|
||||||
|
delete = tables.LinkColumn('member:user_alias_delete',
|
||||||
|
args=[A('pk')],
|
||||||
|
attrs={
|
||||||
|
'td': {'class':'col-sm-2'},
|
||||||
|
'a': {'class': 'btn btn-danger'} },
|
||||||
|
text='delete',accessor='pk')
|
||||||
|
|
|
@ -47,10 +47,10 @@
|
||||||
|
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<form action="" method="post">
|
<form class=" text-center form my-2" action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form |crispy }}
|
{{ form |crispy }}
|
||||||
<button class="btn btn-primary" type="submit">
|
<button class="btn btn-primary mx-2" type="submit">
|
||||||
{% trans "Add alias" %}
|
{% trans "Add alias" %}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue