Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
send registered information as a sentry logging record.
Browse files Browse the repository at this point in the history
this is hugely easier than by email.
the button is disabled after the first registration attempt.
a user can open the window again and send a second registration, but I suppose people will not do that too often.
closes #242
  • Loading branch information
mfrasca committed Dec 29, 2015
1 parent 88a0492 commit 358e1f8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions bauble/plugins/garden/institution.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,32 @@ def on_email_text_entry_changed(self, widget, value=None):
'inst_register', self.email_regexp.match(value or ''))

def on_inst_register_clicked(self, *args, **kwargs):
from bauble.utils import desktop
desktop.open('mailto:bauble@anche.no')
'''send the registration data as sentry info log message
'''

# create the handler first
from raven import Client
from raven.handlers.logging import SentryHandler
sentry_client = Client('https://59105d22a4ad49158796088c26bf8e4c:'
'00268114ed47460b94ce2b1b0b2a4a20@'
'app.getsentry.com/45704')
handler = SentryHandler(sentry_client)
handler.setLevel(logging.INFO)

# the registration logger gets the above handler
registrations = logging.getLogger('bauble.registrations')
registrations.setLevel(logging.INFO)
registrations.addHandler(handler)

# produce the log record
registrations.info([(key, getattr(self.model, key))
for key in self.widget_to_field_map.values()])

# remove the handler after usage
registrations.removeHandler(handler)

# disable button, so user will not send registration twice
self.view.widget_set_sensitive('inst_register', False)

def on_inst_addr_tb_changed(self, widget, value=None, attr=None):
return self.on_textbuffer_changed(widget, value, attr='address')
Expand Down

0 comments on commit 358e1f8

Please sign in to comment.