changeset 521d1943fa23 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=521d1943fa23
description:
Manage readonly dates and editable calendar view
If any of the dates is readonly, the event can not be modified by drag
and
drop.
If the calendar is not editable no events can be modified.
issue9012
review256451002
diffstat:
CHANGELOG | 3 ++
setup.py | 2 +-
tryton/gui/window/view_form/view/calendar_.py | 7 ++++-
tryton/gui/window/view_form/view/calendar_gtk/calendar_.py | 18 +++++++++++++-
4 files changed, 27 insertions(+), 3 deletions(-)
diffs (96 lines):
diff -r d9b582ad6099 -r 521d1943fa23 CHANGELOG
--- a/CHANGELOG Sat Feb 29 23:37:07 2020 +0100
+++ b/CHANGELOG Sat Feb 29 23:43:50 2020 +0100
@@ -1,3 +1,6 @@
+* Manage readonly dates in calendar view
+* Manage editable on calendar view
+* Manage model access on calendar view
* Set client title at the end of header bar
* Manage named separator as label
* Add MultiSelection entry to Dict field
diff -r d9b582ad6099 -r 521d1943fa23 setup.py
--- a/setup.py Sat Feb 29 23:37:07 2020 +0100
+++ b/setup.py Sat Feb 29 23:43:50 2020 +0100
@@ -141,7 +141,7 @@
'PyGObject',
],
extras_require={
- 'calendar': ['GooCalendar>=0.5'],
+ 'calendar': ['GooCalendar>=0.7'],
},
zip_safe=False,
test_suite='tryton.tests',
diff -r d9b582ad6099 -r 521d1943fa23
tryton/gui/window/view_form/view/calendar_.py
--- a/tryton/gui/window/view_form/view/calendar_.py Sat Feb 29 23:37:07
2020 +0100
+++ b/tryton/gui/window/view_form/view/calendar_.py Sat Feb 29 23:43:50
2020 +0100
@@ -15,6 +15,8 @@
Calendar_ = None
Toolbar = None
+from tryton.common import MODELACCESS
+
_ = gettext.gettext
@@ -120,7 +122,10 @@
self.record = None
def on_day_activated(self, goocalendar, day):
- self.screen.new()
+ model_access = MODELACCESS[self.screen.model_name]
+ if (bool(int(self.attributes.get('editable', 1)))
+ and model_access['create']):
+ self.screen.new()
def __getitem__(self, name):
return None
diff -r d9b582ad6099 -r 521d1943fa23
tryton/gui/window/view_form/view/calendar_gtk/calendar_.py
--- a/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py Sat Feb
29 23:37:07 2020 +0100
+++ b/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py Sat Feb
29 23:43:50 2020 +0100
@@ -5,6 +5,8 @@
import goocalendar
from .dates_period import DatesPeriod
+from tryton.common import MODELACCESS
+
class Calendar_(goocalendar.Calendar):
'Calendar'
@@ -90,13 +92,20 @@
event_store = goocalendar.EventStore()
+ model_access = MODELACCESS[self.view_calendar.screen.model_name]
+ editable = (
+ bool(int(self.view_calendar.attributes.get('editable', 1)))
+ and model_access['write'])
+
for record in group:
if not record[dtstart].get(record):
continue
start = record[dtstart].get_client(record)
+ record[dtstart].state_set(record)
if dtend:
end = record[dtend].get_client(record)
+ record[dtend].state_set(record)
else:
end = None
midnight = datetime.time(0)
@@ -113,8 +122,15 @@
text_color, bg_color = self.get_colors(record)
label = '\n'.join(record[attrs['name']].get_client(record)
for attrs in self.fields).rstrip()
+ event_editable = (
+ editable
+ and not record[dtstart].get_state_attrs(record).get(
+ 'readonly', False)
+ and (not dtend
+ or not record[dtend].get_state_attrs(record).get(
+ 'readonly', False)))
event = goocalendar.Event(label, start, end, text_color=text_color,
- bg_color=bg_color, all_day=all_day)
+ bg_color=bg_color, all_day=all_day, editable=event_editable)
event.record = record
event_store.add(event)
self.event_store = event_store