Skip to content

Commit

Permalink
Dev (#126)
Browse files Browse the repository at this point in the history
* Added online fee breakdown to !giving

* Added online Fees to !giving command

* Fixed fee Total math

* corrections to fee calculation for !giving

* Added !forms command

* locked more-itertools==5.0.0 for python 2.7

* Seth Birthday announcements to filter out inactive status
  • Loading branch information
pastorhudson authored Mar 8, 2019
1 parent 5b3f519 commit 48d25fe
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docker-dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

1 change: 1 addition & 0 deletions docker/docker/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ENV PACKAGES="\
python2 \
py-setuptools \
libffi-dev \
openssl-dev \
"
# Maintainer
# ----------
Expand Down
4 changes: 2 additions & 2 deletions plugins/pco/acl_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion plugins/pco/announcements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions plugins/pco/birthday.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions plugins/pco/giving_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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())
20 changes: 19 additions & 1 deletion plugins/pco/pcoannouncements.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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<announcement>.*?(?=(?:\?)|$))", acl=["admins"])
Expand Down
1 change: 1 addition & 0 deletions plugins/pco/set_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions will/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,3 +28,4 @@ requests>=2.19.1,<3
six==1.10.0
urllib3[secure]
websocket-client==0.44.0

0 comments on commit 48d25fe

Please sign in to comment.