mixin.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. from flask_babel import lazy_gettext as _
  18. from ..base import check_ownership
  19. from .filters import DashboardFilter
  20. class DashboardMixin: # pylint: disable=too-few-public-methods
  21. list_title = _("Dashboards")
  22. show_title = _("Show Dashboard")
  23. add_title = _("Add Dashboard")
  24. edit_title = _("Edit Dashboard")
  25. list_columns = ["dashboard_link", "creator", "published", "modified"]
  26. order_columns = ["dashboard_link", "modified", "published"]
  27. edit_columns = [
  28. "dashboard_title",
  29. "slug",
  30. "owners",
  31. "position_json",
  32. "css",
  33. "json_metadata",
  34. "published",
  35. ]
  36. show_columns = edit_columns + ["table_names", "charts"]
  37. search_columns = ("dashboard_title", "slug", "owners", "published")
  38. add_columns = edit_columns
  39. base_order = ("changed_on", "desc")
  40. description_columns = {
  41. "position_json": _(
  42. "This json object describes the positioning of the widgets in "
  43. "the dashboard. It is dynamically generated when adjusting "
  44. "the widgets size and positions by using drag & drop in "
  45. "the dashboard view"
  46. ),
  47. "css": _(
  48. "The CSS for individual dashboards can be altered here, or "
  49. "in the dashboard view where changes are immediately "
  50. "visible"
  51. ),
  52. "slug": _("To get a readable URL for your dashboard"),
  53. "json_metadata": _(
  54. "This JSON object is generated dynamically when clicking "
  55. "the save or overwrite button in the dashboard view. It "
  56. "is exposed here for reference and for power users who may "
  57. "want to alter specific parameters."
  58. ),
  59. "owners": _("Owners is a list of users who can alter the dashboard."),
  60. "published": _(
  61. "Determines whether or not this dashboard is "
  62. "visible in the list of all dashboards"
  63. ),
  64. }
  65. base_filters = [["slice", DashboardFilter, lambda: []]]
  66. label_columns = {
  67. "dashboard_link": _("Dashboard"),
  68. "dashboard_title": _("Title"),
  69. "slug": _("Slug"),
  70. "charts": _("Charts"),
  71. "owners": _("Owners"),
  72. "creator": _("Creator"),
  73. "modified": _("Modified"),
  74. "position_json": _("Position JSON"),
  75. "css": _("CSS"),
  76. "json_metadata": _("JSON Metadata"),
  77. "table_names": _("Underlying Tables"),
  78. }
  79. def pre_delete(self, item): # pylint: disable=no-self-use
  80. check_ownership(item)