1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-24 00:12:23 +00:00

front improvement on alias page

This commit is contained in:
Pierre-antoine Comby 2020-03-01 13:42:22 +01:00
parent 35d5bcdf0f
commit b7e68722aa
5 changed files with 21 additions and 11 deletions

View File

@ -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)

View File

@ -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

View File

@ -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."),

View File

@ -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')

View File

@ -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>