diff --git a/docker-dev/docker-compose.yml b/docker-dev/docker-compose.yml index 0f46540f..c11bb30b 100644 --- a/docker-dev/docker-compose.yml +++ b/docker-dev/docker-compose.yml @@ -14,6 +14,8 @@ services: volumes: - ../plugins/pco:/opt/will/plugins/pco - ../will/templates:/opt/will/templates + - ../will/backends:/opt/will/backends + - ../will/mixins:/opt/will/mixins - ../will/plugins:/opt/will/plugins - ./config.py:/opt/will/config.py depends_on: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5ae89b5e..8d053a4c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,8 +12,8 @@ services: env_file: - default.env volumes: - - ./plugins:/opt/will/plugins - - ./config.py:/opt/will/config.py + - ../plugins:/opt/plugins + - ../config.py:/opt/will/config.py depends_on: - redis diff --git a/docker/docker/dev/Dockerfile b/docker/docker/dev/Dockerfile index 503e3e62..7f310671 100644 --- a/docker/docker/dev/Dockerfile +++ b/docker/docker/dev/Dockerfile @@ -10,6 +10,7 @@ ENV PACKAGES="\ python2 \ py-setuptools \ libffi-dev \ + openssl-dev \ " # Maintainer # ---------- diff --git a/plugins/pco/acl_admin.py b/plugins/pco/acl_admin.py index 420d0dcf..c795a503 100644 --- a/plugins/pco/acl_admin.py +++ b/plugins/pco/acl_admin.py @@ -12,8 +12,8 @@ def acl_lookup(self, message, acl_list): msg = "" attachment = [] acl_groups = get_acl_groups() - for acl in acl_groups: - print(acl) + for acl_grp in acl_groups: + print(acl_grp) msg += "*" + acl + ":*\n" print(msg) for x in get_acl_members(acl): diff --git a/plugins/pco/announcements.py b/plugins/pco/announcements.py index 32fea419..b8668513 100644 --- a/plugins/pco/announcements.py +++ b/plugins/pco/announcements.py @@ -3,7 +3,7 @@ def get_slack_channel_link(will, new_channel): - """Retrieves a slack formated link from a channel name. This should probably be moved somewhere else.""" + """Retrieves a slack formatted link from a channel name. This should probably be moved somewhere else.""" channels = will.load("slack_channel_cache") channel = None for key in channels: diff --git a/plugins/pco/birthday.py b/plugins/pco/birthday.py index 923d5e3b..b1cf08ff 100644 --- a/plugins/pco/birthday.py +++ b/plugins/pco/birthday.py @@ -47,8 +47,8 @@ def get_todays_birthdays(): msg = "*Today's Birthdays!*\n" today = datetime.datetime.today().strftime('%m-%d') for x in pco.people.people.list(): - if today in str(x.birthdate)[5:]: - msg += "%s\n" % x.name + if today in str(x.birthdate)[5:] and x.status == 'active': + msg += "%s\n" % x.name attachment = msg_attachment.SlackAttachment(fallback=msg, text=msg) return attachment diff --git a/plugins/pco/giving_report.py b/plugins/pco/giving_report.py index 3db2a6dd..197f3e9d 100644 --- a/plugins/pco/giving_report.py +++ b/plugins/pco/giving_report.py @@ -17,7 +17,7 @@ # print("Today: %s" % today) -def get_giving(report_date=None): +def get_giving(report_date="Last Monday"): fund_totals = {} online_giving = 0 total_giving = 0 @@ -27,10 +27,11 @@ def get_giving(report_date=None): if parse_status: report_date = datetime.datetime(*report_date[:6]) report_date = report_date.strftime('%Y-%m-%d') - msg = "Giving Since: %s" % report_date + "\n" + msg = "Giving: %s - %s" % (report_date, datetime.date.today()) + "\n" for donation in pco.giving.donations.list(where={"[created_at][gte]": report_date}, include={'designations, labels'}): - + for label in donation.rel.labels.list(): + print(label.attributes['slug']) if donation.payment_method == 'ach' or donation.payment_method == 'card': online_giving += donation.amount_cents @@ -61,6 +62,6 @@ def get_giving(report_date=None): if __name__ == '__main__': - x = get_giving("last sunday") + x = get_giving() for attachment in x: print(attachment.slack()) \ No newline at end of file diff --git a/plugins/pco/pcoannouncements.py b/plugins/pco/pcoannouncements.py index b571ee5e..f04e5064 100644 --- a/plugins/pco/pcoannouncements.py +++ b/plugins/pco/pcoannouncements.py @@ -1,6 +1,6 @@ from will.plugin import WillPlugin from will.decorators import respond_to, periodic, hear, randomly, route, rendered_template, require_settings -from plugins.pco import birthday, msg_attachment, announcements +from plugins.pco import birthday, msg_attachment, announcements, giving_report import logging @@ -13,6 +13,24 @@ def announce_birthdays(self): if announcements.announcement_is_enabled(self, announcement='birthdays'): birthday.announce_todays_birthdays(self, channel=announcements.announcement_channel(self)) + @periodic(day='Sunday', hour='15') + # @periodic(second=0) + # @hear("(!test_giving)", acl=["admins"]) + def report_giving(self, message): + # if announcements.announcement_is_enabled(self, announcement='giving'): + g_report = giving_report.get_giving(report_date="Last Monday") + for g in g_report: + attachment = g.slack() + self.say("Giving Report", attachments=attachment, channel='giving') + + @hear("(!test_giving)", acl=["admins"]) + def report_giving(self, message): + # if announcements.announcement_is_enabled(self, announcement='giving'): + g_report = giving_report.get_giving(report_date="Last Monday") + for g in g_report: + attachment = g.slack() + self.say("Giving Report", attachments=attachment, channel='giving') + # @periodic(hour='14', minute='10') # at a certain time # @periodic(second=0) # every minute at 0 seconds @hear("(!announce)(?P.*?(?=(?:\?)|$))", acl=["admins"]) diff --git a/plugins/pco/set_list.py b/plugins/pco/set_list.py index dd26851d..e33655d8 100644 --- a/plugins/pco/set_list.py +++ b/plugins/pco/set_list.py @@ -18,6 +18,7 @@ def get(set_date="sunday"): attachment_list = [] # Get the Order of Service of a date and return a formatted string ready to send back. # This only works for future dates since PCO API doesn't let us quarry plans by date. + # TODO PCO added ability to query plans by date cal = parsedatetime.Calendar() set_date, parse_status = cal.parse(set_date) set_date = datetime.datetime(*set_date[:6]) diff --git a/will/requirements/base.txt b/will/requirements/base.txt index d5391e38..36fa48b6 100644 --- a/will/requirements/base.txt +++ b/will/requirements/base.txt @@ -9,6 +9,7 @@ fuzzywuzzy==0.15.1 Jinja2==2.7.3 Markdown==2.3.1 MarkupSafe==0.23 +more-itertools==5.0.0 # Temporary fork of natural, until python 3 support is merged: https://github.com/tehmaze/natural/pull/13 # natural==0.2.1 will-natural==0.2.1.1 @@ -27,3 +28,4 @@ requests>=2.19.1,<3 six==1.10.0 urllib3[secure] websocket-client==0.44.0 +