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.note = self.object.note
|
||||
alias.save()
|
||||
alias.note.save()
|
||||
print(alias,alias.pk)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
@ -202,7 +201,7 @@ class DeleteAliasView(LoginRequiredMixin, DeleteView):
|
|||
messages.error(self.request,str(e))
|
||||
else:
|
||||
messages.success(self.request,_("Alias successfully deleted"))
|
||||
return HttpResponseRedirect(get_success_url)
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
print(self.request)
|
||||
|
|
|
@ -12,8 +12,12 @@ class AliasForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = Alias
|
||||
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 Meta:
|
||||
model = TransactionTemplate
|
||||
|
|
|
@ -227,12 +227,13 @@ class Alias(models.Model):
|
|||
try:
|
||||
sim_alias = Alias.objects.get(normalized_name=normalized_name)
|
||||
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"
|
||||
)
|
||||
except Alias.DoesNotExist:
|
||||
pass
|
||||
|
||||
self.normalized_name = normalized_name
|
||||
|
||||
def delete(self, using=None, keep_parents=False):
|
||||
if self.name == str(self.note):
|
||||
raise ValidationError(_("You can't delete your main alias."),
|
||||
|
|
|
@ -32,8 +32,14 @@ class AliasTable(tables.Table):
|
|||
'table table condensed table-striped table-hover'
|
||||
}
|
||||
model = Alias
|
||||
fields = ('name','pk')
|
||||
fields =('name',)
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
|
||||
delete = tables.LinkColumn('member:user_alias_delete', args=[A('pk')], attrs={
|
||||
'a': {'class': 'btn btn-danger'} },text='delete',accessor='pk')
|
||||
show_header = False
|
||||
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="d-flex justify-content-center">
|
||||
<form action="" method="post">
|
||||
<form class=" text-center form my-2" action="" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form |crispy }}
|
||||
<button class="btn btn-primary" type="submit">
|
||||
<button class="btn btn-primary mx-2" type="submit">
|
||||
{% trans "Add alias" %}
|
||||
</button>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue