Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
1bd94fc4
Commit
1bd94fc4
authored
5 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
Use TableView for conso page
parent
456d192b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
apps/note/forms.py
+1
-31
1 addition, 31 deletions
apps/note/forms.py
apps/note/tables.py
+1
-1
1 addition, 1 deletion
apps/note/tables.py
apps/note/views.py
+10
-11
10 additions, 11 deletions
apps/note/views.py
templates/note/conso_form.html
+1
-1
1 addition, 1 deletion
templates/note/conso_form.html
with
13 additions
and
44 deletions
apps/note/forms.py
+
1
−
31
View file @
1bd94fc4
...
...
@@ -6,7 +6,7 @@ from django import forms
from
django.utils.translation
import
gettext_lazy
as
_
from
.models
import
Alias
from
.models
import
Transaction
,
TransactionTemplate
,
TemplateTransaction
from
.models
import
Transaction
,
TransactionTemplate
class
AliasForm
(
forms
.
ModelForm
):
...
...
@@ -99,33 +99,3 @@ class TransactionForm(forms.ModelForm):
},
),
}
class
ConsoForm
(
forms
.
ModelForm
):
def
save
(
self
,
commit
=
True
):
button
:
TransactionTemplate
=
TransactionTemplate
.
objects
.
filter
(
name
=
self
.
data
[
'
button
'
]).
get
()
self
.
instance
.
destination
=
button
.
destination
self
.
instance
.
amount
=
button
.
amount
self
.
instance
.
reason
=
'
{} ({})
'
.
format
(
button
.
name
,
button
.
category
)
self
.
instance
.
template
=
button
self
.
instance
.
category
=
button
.
category
super
().
save
(
commit
)
class
Meta
:
model
=
TemplateTransaction
fields
=
(
'
source
'
,)
# Le champ d'utilisateur est remplacé par un champ d'auto-complétion.
# Quand des lettres sont tapées, une requête est envoyée sur l'API d'auto-complétion
# et récupère les aliases de note valides
widgets
=
{
'
source
'
:
autocomplete
.
ModelSelect2
(
url
=
'
note:note_autocomplete
'
,
attrs
=
{
'
data-placeholder
'
:
'
Note ...
'
,
'
data-minimum-input-length
'
:
1
,
},
),
}
This diff is collapsed.
Click to expand it.
apps/note/tables.py
+
1
−
1
View file @
1bd94fc4
...
...
@@ -6,7 +6,7 @@ from django.db.models import F
from
django_tables2.utils
import
A
from
.models.notes
import
Alias
from
.models.transactions
import
Transaction
,
TransactionTemplate
from
.models.transactions
import
Transaction
from
.templatetags.pretty_money
import
pretty_money
...
...
This diff is collapsed.
Click to expand it.
apps/note/views.py
+
10
−
11
View file @
1bd94fc4
...
...
@@ -7,9 +7,11 @@ from django.db.models import Q
from
django.urls
import
reverse
from
django.utils.translation
import
gettext_lazy
as
_
from
django.views.generic
import
CreateView
,
ListView
,
UpdateView
from
django_tables2
import
SingleTableView
from
.forms
import
TransactionForm
,
TransactionTemplateForm
,
ConsoForm
from
.models
import
Transaction
,
TransactionTemplate
,
Alias
,
TemplateTransaction
from
.forms
import
TransactionForm
,
TransactionTemplateForm
from
.models
import
Transaction
,
TransactionTemplate
,
Alias
from
.tables
import
HistoryTable
class
TransactionCreate
(
LoginRequiredMixin
,
CreateView
):
...
...
@@ -121,13 +123,16 @@ class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
form_class
=
TransactionTemplateForm
class
ConsoView
(
LoginRequiredMixin
,
Creat
eView
):
class
ConsoView
(
LoginRequiredMixin
,
SingleTabl
eView
):
"""
Consume
"""
model
=
Template
Transaction
model
=
Transaction
template_name
=
"
note/conso_form.html
"
form_class
=
ConsoForm
# Transaction history table
table_class
=
HistoryTable
table_pagination
=
{
"
per_page
"
:
10
}
def
get_context_data
(
self
,
**
kwargs
):
"""
...
...
@@ -142,9 +147,3 @@ class ConsoView(LoginRequiredMixin, CreateView):
context
[
'
no_cache
'
]
=
True
return
context
def
get_success_url
(
self
):
"""
When clicking a button, reload the same page
"""
return
reverse
(
'
note:consos
'
)
This diff is collapsed.
Click to expand it.
templates/note/conso_form.html
+
1
−
1
View file @
1bd94fc4
{% extends "base.html" %}
{% load i18n static pretty_money %}
{% load i18n static pretty_money
django_tables2
%}
{# Remove page title #}
{% block contenttitle %}{% endblock %}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment