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

Enhance iCal file exports #162

Merged
merged 10 commits into from Mar 28, 2015
Merged

Conversation

rtnpro
Copy link
Contributor

@rtnpro rtnpro commented Jan 28, 2015

This branch improves export of iCal files in the following ways:

  • Allow export iCal file for a calendar event
  • Add reminder logic in iCal file
  • when downloading iCal info for a meeting, allow the option to add a reminder as well.

NOTE: This is work in progress and the PR has been created for review of ongoing work.

@pypingou
Copy link
Member

This is a nice start.
Had you kept #161 open I would have asked if you could adjust the unit-tests and I would have merged it, now I have to wait ;-)

@rtnpro
Copy link
Contributor Author

rtnpro commented Jan 29, 2015

@pypingou I can reopen #161 then, and add unit tests in it :)

@pypingou
Copy link
Member

@rtnpro sure, works for me :)

@rtnpro
Copy link
Contributor Author

rtnpro commented Feb 20, 2015

@pypingou Could you review it?

Changes:

  • Add reminders in iCal file
  • Allow option in meeting snippet to export meeting ical with/without reminders
  • Allow configuring ical reminders from config file

@rtnpro
Copy link
Contributor Author

rtnpro commented Feb 20, 2015

@pypingou if the above is OK, I will add tests for the same.

@@ -59,3 +59,6 @@ APP_URL = 'https://apps.fedoraproject.org/calendar/'
### In case of exception flask sends an email with some information to debug the
### problem. The email is sent to the address listed here.
# EMAIL_ERROR = 'pingou@pingoured.fr'

ICAL_REMINDERS = [{'days': -1}, {'hours': -1}, {'minutes': -5}]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to sync this with the default configuration and we should document a little more in the sample configuration

Changes summary:
- 'ICAL_REMINDERS' in conf file replaced with 'ICAL_REMINDER_OPTIONS' for displaying
  dropdown menu for selecting reminder time when downloading a meeting's iCal file
  with a reminder.
- Change in GET param: 'reminder' to 'reminder_at' for exporting iCal file for a
  meeting.
- Change in 'add_meeting_to_vcal' API to accept no or single reminder rather
  than a list of reminders.
@rtnpro
Copy link
Contributor Author

rtnpro commented Mar 2, 2015

@pypingou Please review rtnpro@c99762f. Please have a look at the commit summary for a summary of the changes made.

@rtnpro
Copy link
Contributor Author

rtnpro commented Mar 3, 2015

@pypingou True! Currently the flow would allow setting reminders after the meeting if the user toys around the URL :) However, I wanted to keep the get_timestamp_from_str generic and wanted to have the policy: reminder can be set before the event in the view layer. However, values like: 5 for 5 minutes, 60 for 1 hour and 60*24=1440 for 1 day seems simple and better. However, I am not able to think of a nice get parameter name for it. The param should explicitly mention the reminder is set at a time before the meeting. reminder_at needed - sign to indicate it. reminder_before won't need any sign before its value as the name itself says it all. But, I don't find the name reminder_before nice :. What do you say?

'reminder_delta=<minutes before meeting>' instead of
'reminder_at=<-?(?:\d+h)?(?:\d+m)?(?:\d+s)?>'. This leads to
a simple way (int(reminder_delta)) to extract minutes before
event info for setting reminder in the iCal file.
@@ -1030,7 +1038,9 @@ def view_meeting_page(meeting_id, full):
tzone=tzone,
title=meeting.meeting_name,
editor=editor,
from_date=from_date)
from_date=from_date,
reminder_at_options=APP.config.get('ICAL_REMINDER_AT_OPTIONS') or []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the or here, just finish the get:
reminder_at_options=APP.config.get('ICAL_REMINDER_AT_OPTIONS', [])
The second parameter is the default to return if the key is not in the dict ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pypingou I know, but
reminder_at_options=APP.config.get('ICAL_REMINDER_AT_OPTIONS') or []
handles the worst case scenario when

config[ICAL_REMINDER_AT_OPTIONS'] = None

It's unnecessary here. It's a side effect of writing fault tolerant code for E Commerce products to handle stupidity from some other sources ;). Here, it's unnecessary, I believe. I will fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be able to have
config[ICAL_REMINDER_AT_OPTIONS'] = None
as it would mean someone edited the default_config.py instead of overriding it.

So +1 on not being tolerant to this, but in the worst case, I think I would prefer a if reminder_at_options lower down the stack.

@rtnpro
Copy link
Contributor Author

rtnpro commented Mar 6, 2015

@pypingou I have added tests for this feature enhancement. Please review it.

@@ -54,10 +54,25 @@ <h2 class="orange">{{ _('Meeting "%(name)s"', name=meeting.meeting_name) }}</h2>
{% endmacro %}
<p>{{ _('Meeting organized by %(managers)s', managers=get_managers(meeting.meeting_manager)) }}</p>

<a href="{{ url_for('ical_calendar_meeting', meeting_id=meeting.meeting_id) }}"
<a id="ical-meeting-export" href="{{ url_for('ical_calendar_meeting', meeting_id=meeting.meeting_id) }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to place the id on the line below to keep (more or less) the 80 char rule :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@pypingou
Copy link
Member

This is looking very nice and working nicely as well locally.

Two questions still and one remark: the tests are currently failing for me here :)

FAIL: Test the view_meeting_page function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pingou/repos/gitrepo/fedocal/tests/test_flask.py", line 494, in test_view_meeting_page
    in output.data)
AssertionError: False is not true

@rtnpro
Copy link
Contributor Author

rtnpro commented Mar 18, 2015

@pypingou I am looking into the above, and I will fix it ASAP.

- Test for non-numeric values of reminder_delta GET param when exporting ical
  file for a meeting.
- Test for a reminder_delta value not in default choices for reminder_delta.
@rtnpro
Copy link
Contributor Author

rtnpro commented Mar 28, 2015

@pypingou I have moved the refactor related to static js files in another branch. I have also added the remainder tests that you'd mentioned. Please review it and let me know if it's ready for merge.

Please note that JS issues related to ical reminder UI elements persist for meeting details page. This has been already fixed in the branch for JS refactor.

@pypingou
Copy link
Member

This is looking really good!

I'm just going to wait for jenkins to kick in and then merge.

pypingou added a commit that referenced this pull request Mar 28, 2015
@pypingou pypingou merged commit aca7a56 into fedora-infra:master Mar 28, 2015
@ralphbean
Copy link
Contributor

Hooray!

🏯 This was epic. 🏰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants