aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-14 14:13:03 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-14 14:13:03 +0200
commit758c16c3424aa59c173ccad7ca2c311f1d817001 (patch)
tree4b9cc330834d9480c37348d9e92256084c0d0ad0 /bot
parentMake Meetbot tests cleaner, fix one bug found in the process (diff)
downloadcouncil-webapp-758c16c3424aa59c173ccad7ca2c311f1d817001.tar.gz
council-webapp-758c16c3424aa59c173ccad7ca2c311f1d817001.tar.bz2
council-webapp-758c16c3424aa59c173ccad7ca2c311f1d817001.zip
Disable agenda management by default
Reasons: * Users may not want it, so they should be able to turn it off * Tests don't fail when localhost:3000 is unreachable * Make tests faster.
Diffstat (limited to 'bot')
-rw-r--r--bot/ircmeeting/agenda.py16
-rw-r--r--bot/ircmeeting/meeting.py1
-rw-r--r--bot/tests/run_test.py1
3 files changed, 18 insertions, 0 deletions
diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py
index e3f456c..247907b 100644
--- a/bot/ircmeeting/agenda.py
+++ b/bot/ircmeeting/agenda.py
@@ -27,12 +27,16 @@ class Agenda(object):
self.conf = conf
def get_agenda_item(self):
+ if not self.conf.manage_agenda:
+ return('')
if self._current_item < len(self._agenda):
return str.format(self.current_item_msg, self._agenda[self._current_item][0])
else:
return self.empty_agenda_msg
def next_agenda_item(self):
+ if not self.conf.manage_agenda:
+ return('')
if self._vote_open:
return voting_open_so_item_not_changed_msg
else:
@@ -41,6 +45,8 @@ class Agenda(object):
return(self.get_agenda_item())
def prev_agenda_item(self):
+ if not self.conf.manage_agenda:
+ return('')
if self._vote_open:
return voting_open_so_item_not_changed_msg
else:
@@ -49,6 +55,8 @@ class Agenda(object):
return(self.get_agenda_item())
def start_vote(self):
+ if not self.conf.manage_agenda:
+ return('')
if self._vote_open:
return self.voting_already_open_msg
self._vote_open = True
@@ -58,12 +66,16 @@ class Agenda(object):
return str.format(self.voting_open_msg, options)
def end_vote(self):
+ if not self.conf.manage_agenda:
+ return('')
if self._vote_open:
self._vote_open = False
return self.voting_already_closed_msg
return voting_close_msg
def get_data(self):
+ if not self.conf.manage_agenda:
+ return('')
self._voters = self._get_json(self.conf.voters_url)
self._agenda = self._get_json(self.conf.agenda_url)
self._votes = { }
@@ -71,6 +83,8 @@ class Agenda(object):
self._votes[i[0]] = { }
def vote(self, nick, line):
+ if not self.conf.manage_agenda:
+ return('')
if not nick in self._voters:
return str.format(self.can_not_vote_msg, ", ".join(self._voters))
if not line.isdigit():
@@ -91,6 +105,8 @@ class Agenda(object):
return result
def post_result(self):
+ if not self.conf.manage_agenda:
+ return('')
data = urllib.quote(json.dumps([self._votes]))
result_url = str.format(self.conf.result_url,
self.conf.voting_results_user,
diff --git a/bot/ircmeeting/meeting.py b/bot/ircmeeting/meeting.py
index 108ae1d..26138a2 100644
--- a/bot/ircmeeting/meeting.py
+++ b/bot/ircmeeting/meeting.py
@@ -105,6 +105,7 @@ class Config(object):
# Credentials for posting voting results
voting_results_user = 'user'
voting_results_password = 'password'
+ manage_agenda = False
def enc(self, text):
return text.encode(self.output_codec, 'replace')
diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py
index 79bb9d7..f4e6e49 100644
--- a/bot/tests/run_test.py
+++ b/bot/tests/run_test.py
@@ -344,6 +344,7 @@ class MeetBotTest(unittest.TestCase):
"""
test = test_meeting.TestMeeting()
+ test.M.config.manage_agenda = True
test.set_voters(['x', 'z'])
test.set_agenda([['first item', ['opt1', 'opt2']], ['second item', []]])
test.process("""