Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-35078:Allow customization of CSS class name of a month in calendar module #10137

Merged
merged 3 commits into from Jun 2, 2020
Merged

bpo-35078:Allow customization of CSS class name of a month in calendar module #10137

merged 3 commits into from Jun 2, 2020

Conversation

srinivasreddy
Copy link
Contributor

@srinivasreddy srinivasreddy commented Oct 26, 2018

Lib/calendar.py Outdated Show resolved Hide resolved
@tirkarthi
Copy link
Member

tirkarthi commented Oct 26, 2018

Tests could be added for the new change at

local_month = cal.formatmonthname(2010, 10)

self.assertIn('class="month"', local_month)
cal.cssclass_month_head = "text-center month"
local_month = cal.formatmonthname(2010, 10)
self.assertIn('class="text-center month"', local_month)

A NEWS entry might help with the change.

Thanks for the PR :)

@srinivasreddy srinivasreddy changed the title bpo-35078: Allow customization of css class for the HTML table header bpo-35078:Refactor code in calendar.py module Oct 27, 2018
Copy link
Member

@tirkarthi tirkarthi left a comment

I would suggest adding the actual change done to the NEWS entry in addition to the current text like

The month's head CSS class in :class:`calendar.LocaleHTMLCalendar`
is now customizable with attribute ``cssclass_month_head``.

It's more of a personal opinion and would leave it to the reviewer to consider the wording. Other than that LGTM. Thanks for your contribution :)

@srinivasreddy srinivasreddy changed the title bpo-35078:Refactor code in calendar.py module bpo-35078:Allow customization of CSS class name of a month in calendar module Oct 27, 2018
@doerwalter
Copy link
Contributor

doerwalter commented Feb 19, 2019

The code looks good to me. There's no additional test for LocaleTextCalendar, but that's ok, as there should be no behaviour changes from the patch.

However there's no test for the changed method LocaleHTMLCalendar.formatweekday.

Furthermore the NEWS entry is misleading (and as Serhiy noted on bpo: "We don't usually do pure refactoring changes"). I'd use something like: "Refactor formatweekday, formatmonthname methods in LocaleHTMLCalendar and LocaleTextCalendar classes in calendar module to call the base class methods. This enables customizable CSS classes for LocaleHTMLCalendar.
Patch by Srinivas Reddy Thatiparthy."

If you could add a test for LocaleHTMLCalendar.formatweekday and update the NEWS entry, IMHO the patch is good to go.

@srinivasreddy
Copy link
Contributor Author

srinivasreddy commented Feb 25, 2019

Sure @doerwalter

@csabella csabella requested a review from doerwalter Dec 14, 2019
@doerwalter
Copy link
Contributor

doerwalter commented Dec 16, 2019

There's still a test missing for the changed formatweekday method, i.e. something like:

-    def test_locale_html_calendar_custom_css_class(self):
+    def test_locale_html_calendar_custom_css_class_month_name(self):
         try:
             cal = calendar.LocaleHTMLCalendar(locale='')
             local_month = cal.formatmonthname(2010, 10, 10)
@@ -576,6 +576,19 @@ class CalendarTestCase(unittest.TestCase):
         local_month = cal.formatmonthname(2010, 10, 10)
         self.assertIn('class="text-center month"', local_month)

+    def test_locale_html_calendar_custom_css_class_weekday(self):
+        try:
+            cal = calendar.LocaleHTMLCalendar(locale='')
+            local_weekday = cal.formatweekday(6)
+        except locale.Error:
+            # cannot set the system default locale -- skip rest of test
+            raise unittest.SkipTest('cannot set the system default locale')
+        self.assertIn('class="sun"', local_weekday)
+        cal.cssclasses_weekday_head = [ "mon2", "tue2", "wed2", "thu2",
+          "fri2", "sat2", "sun2"]
+        local_weekday = cal.formatweekday(6)
+        self.assertIn('class="sun2"', local_weekday)
+

Otherwise the patch looks good.

Copy link
Contributor

@doerwalter doerwalter left a comment

See my last comment.

@csabella
Copy link
Contributor

csabella commented May 28, 2020

@srinivasreddy, please the last code review request. Thank you!

@srinivasreddy
Copy link
Contributor Author

srinivasreddy commented May 30, 2020

@csabella Thanks

@csabella csabella requested a review from doerwalter May 30, 2020
@doerwalter doerwalter merged commit 85339f5 into python:master Jun 2, 2020
4 checks passed
@srinivasreddy srinivasreddy deleted the 35078 branch Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants