Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
9216858c
Commit
9216858c
authored
5 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix] fix date period selector limits in tx history
parent
f79e5a15
No related branches found
No related tags found
1 merge request
!775
0.50.0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sakia/gui/navigation/txhistory/controller.py
+41
-5
41 additions, 5 deletions
src/sakia/gui/navigation/txhistory/controller.py
with
41 additions
and
5 deletions
src/sakia/gui/navigation/txhistory/controller.py
+
41
−
5
View file @
9216858c
import
logging
from
PyQt5.QtCore
import
QTime
,
pyqtSignal
,
QObject
from
PyQt5.QtCore
import
QTime
,
pyqtSignal
,
QObject
,
QDateTime
from
PyQt5.QtGui
import
QCursor
from
sakia.decorators
import
asyncify
...
...
@@ -125,14 +125,50 @@ class TxHistoryController(QObject):
def
dates_changed
(
self
):
self
.
_logger
.
debug
(
"
Changed dates
"
)
if
self
.
view
.
table_history
.
model
():
qdate_from
=
self
.
view
.
date_from
# capture datetimes from calendar widget
qdate_from
=
self
.
view
.
date_from
.
dateTime
()
# type: QDateTime
qdate_to
=
self
.
view
.
date_to
.
dateTime
()
# type: QDateTime
# time is midnight
qdate_from
.
setTime
(
QTime
(
0
,
0
,
0
))
qdate_to
=
self
.
view
.
date_to
qdate_to
.
setTime
(
QTime
(
0
,
0
,
0
))
ts_from
=
qdate_from
.
dateTime
().
toTime_t
()
ts_to
=
qdate_to
.
dateTime
().
toTime_t
()
# calculate dates
qdate_from_plus_one_year
=
qdate_from
.
addYears
(
1
)
qdate_to_minus_one_month
=
qdate_to
.
addMonths
(
-
1
)
qone_month_ago
=
QDateTime
.
currentDateTime
().
addMonths
(
-
1
)
qtomorrow
=
QDateTime
.
currentDateTime
().
addDays
(
1
)
qtomorrow
.
setTime
(
QTime
(
0
,
0
,
0
))
# if start later than one month ago...
if
qdate_from
>
qone_month_ago
:
# start = now - 1 month
qdate_from
=
qone_month_ago
# if start > end minus one month...
if
qdate_from
>
qdate_to_minus_one_month
:
# end = start + 1 month
qdate_to
=
qdate_from
.
addMonths
(
1
)
# if period is more than one year long...
if
qdate_to
>
qdate_from_plus_one_year
:
# end = start + 1 year
qdate_to
.
setDate
(
qdate_from_plus_one_year
.
date
())
# if end > tomorrow...
if
qdate_to
>
qtomorrow
:
# end = tomorrow
qdate_to
=
qtomorrow
# todo: update minimum and maximum of the calendar to forbid bad dates
# update calendar
self
.
view
.
date_from
.
setDateTime
(
qdate_from
)
self
.
view
.
date_to
.
setDateTime
(
qdate_to
)
# update model in table
ts_from
=
qdate_from
.
toTime_t
()
ts_to
=
qdate_to
.
toTime_t
()
self
.
view
.
table_history
.
model
().
set_period
(
ts_from
,
ts_to
)
# refresh
self
.
refresh_balance
()
self
.
refresh_pages
()
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