Skip to content

Commit

Permalink
Sort praw.models.reddit.widgets.SubredditWidgetsModeration.add_calend…
Browse files Browse the repository at this point in the history
…ar arguments
  • Loading branch information
LilSpazJoekp committed Jan 14, 2022
1 parent 8df424d commit 8acd7ca
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
44 changes: 29 additions & 15 deletions praw/models/reddit/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,22 +552,22 @@ def add_button_widget(
button_widget.update(other_settings)
return self._create_widget(button_widget)

@_deprecate_args(
"short_name", "google_calendar_id", "requires_sync", "configuration", "styles"
)
def add_calendar(
self,
short_name: str,
*,
configuration: Dict[str, Union[bool, int]],
google_calendar_id: str,
requires_sync: bool,
configuration: Dict[str, Union[bool, int]],
short_name: str,
styles: Dict[str, str],
**other_settings,
) -> "praw.models.Calendar":
"""Add and return a :class:`.Calendar` widget.
:param short_name: A name for the widget, no longer than 30 characters.
:param google_calendar_id: An email-style calendar ID. To share a Google
Calendar, make it public, then find the "Calendar ID".
:param requires_sync: A ``bool``.
:param configuration: A ``dict`` as specified in `Reddit docs`_. For example:
:param configuration: A dictionary as specified in `Reddit docs`_. For example:
.. code-block:: python
Expand All @@ -580,9 +580,13 @@ def add_calendar(
"showTitle": True,
}
:param styles: A ``dict`` with keys ``backgroundColor`` and ``headerColor``, and
values of hex colors. For example, ``{"backgroundColor": "#FFFF66",
"headerColor": "#3333EE"}``.
:param google_calendar_id: An email-style calendar ID. To share a Google
Calendar, make it public, then find the "Calendar ID".
:param requires_sync: Whether the calendar needs synchronization.
:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
``"headerColor"``, and values of hex colors. For example,
``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.
:returns: The created :class:`.Calendar`.
Expand All @@ -602,9 +606,13 @@ def add_calendar(
"showTime": True,
"showTitle": True,
}
cal_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
calendar_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
new_widget = widget_moderation.add_calendar(
"Upcoming Events", cal_id, True, config, styles
short_name="Upcoming Events",
google_calendar_id=calendar_id,
requires_sync=True,
configuration=config,
styles=styles,
)
"""
Expand Down Expand Up @@ -1150,7 +1158,7 @@ class ButtonWidget(Widget, BaseList):


class Calendar(Widget):
r"""Class to represent a calendar widget.
"""Class to represent a calendar widget.
Find an existing one:
Expand Down Expand Up @@ -1180,7 +1188,13 @@ class Calendar(Widget):
"showTitle": True,
}
cal_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
calendar = widgets.mod.add_calendar("Upcoming Events", cal_id, True, config, styles)
calendar = widgets.mod.add_calendar(
short_name="Upcoming Events",
google_calendar_id=cal_id,
requires_sync=True,
configuration=config,
styles=styles,
)
For more information on creation, see :meth:`.add_calendar`.
Expand All @@ -1203,7 +1217,7 @@ class Calendar(Widget):
Attribute Description
================= =====================================================
``configuration`` A ``dict`` describing the calendar configuration.
``data`` A list of ``dict``\ s that represent events.
``data`` A list of dictionaries that represent events.
``id`` The widget ID.
``kind`` The widget kind (always ``"calendar"``).
``requiresSync`` A ``bool`` representing whether the calendar requires
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/models/reddit/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ def test_create_and_update_and_delete(self, _):
}
cal_id = "ccahu0rstno2jrvioq4ccffn78@group.calendar.google.com"
widget = widgets.mod.add_calendar(
"Upcoming Events", cal_id, True, config, styles
short_name="Upcoming Events",
google_calendar_id=cal_id,
requires_sync=True,
configuration=config,
styles=styles,
)

assert isinstance(widget, Calendar)
Expand Down

0 comments on commit 8acd7ca

Please sign in to comment.