Mercurial > libervia-backend
annotate frontends/src/jp/cmd_event.py @ 2483:0046283a285d
dates update
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 26 Jan 2018 11:14:13 +0100 |
parents | 8b37a62336c3 |
children | 5895e4daae8c |
rev | line source |
---|---|
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # jp: a SàT command line tool |
2483 | 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 import base |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from sat.core.i18n import _ |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
23 from sat.tools.common.ansi import ANSI as A |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat_frontends.jp.constants import Const as C |
2284
4fd010f29f99
jp (blog, event): added checkURI to some command to be able to enter a xmpp: uri as argument
Goffi <goffi@goffi.org>
parents:
2283
diff
changeset
|
25 from sat_frontends.jp import common |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from functools import partial |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
27 from dateutil import parser as du_parser |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
28 import calendar |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
29 import time |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 __commands__ = ["Event"] |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
33 OUTPUT_OPT_TABLE = u'table' |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
34 |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
35 # TODO: move date parsing to base, it may be useful for other commands |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
36 |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 class Get(base.CommandBase): |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 def __init__(self, host): |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 base.CommandBase.__init__(self, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 host, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 'get', |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 use_output=C.OUTPUT_DICT, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 use_pubsub_node_req=True, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 use_verbose=True, |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
47 help=_(u'get event data')) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
48 self.need_loop=True |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
49 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
50 def add_parser_options(self): |
2283
5b04fc0c663d
jp (pubsub/get): renamed --id option to --item for consistency with other commands
Goffi <goffi@goffi.org>
parents:
2247
diff
changeset
|
51 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, default=u'', help=_(u"ID of the PubSub Item")) |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
52 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
53 def eventInviteeGetCb(self, result): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
54 event_date, event_data = result |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
55 event_data['date'] = event_date |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
56 self.output(event_data) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
57 self.host.quit() |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
58 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
59 def start(self): |
2284
4fd010f29f99
jp (blog, event): added checkURI to some command to be able to enter a xmpp: uri as argument
Goffi <goffi@goffi.org>
parents:
2283
diff
changeset
|
60 common.checkURI(self.args) |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
61 self.host.bridge.eventGet( |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
62 self.args.service, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
63 self.args.node, |
2283
5b04fc0c663d
jp (pubsub/get): renamed --id option to --item for consistency with other commands
Goffi <goffi@goffi.org>
parents:
2247
diff
changeset
|
64 self.args.item, |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
65 self.profile, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
66 callback=self.eventInviteeGetCb, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
67 errback=partial(self.errback, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
68 msg=_(u"can't get event data: {}"), |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
69 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
70 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
71 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
72 class EventBase(object): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
73 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
74 def add_parser_options(self): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
75 self.parser.add_argument("-i", "--id", type=base.unicode_decoder, default=u'', help=_(u"ID of the PubSub Item")) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
76 self.parser.add_argument("-d", "--date", type=unicode, help=_(u"date of the event")) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
77 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
78 metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set")) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
79 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
80 def parseFields(self): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
81 return dict(self.args.fields) if self.args.fields else {} |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
82 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
83 def parseDate(self): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
84 if self.args.date: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
85 try: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
86 date = int(self.args.date) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
87 except ValueError: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
88 try: |
2247
0f3bfe89999e
jp (event): don't use dayfirst for YY-MM-DD style dates
Goffi <goffi@goffi.org>
parents:
2244
diff
changeset
|
89 date_time = du_parser.parse(self.args.date, dayfirst=not (u'-' in self.args.date)) |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
90 except ValueError as e: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
91 self.parser.error(_(u"Can't parse date: {msg}").format(msg=e)) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
92 if date_time.tzinfo is None: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
93 date = calendar.timegm(date_time.timetuple()) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
94 else: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
95 date = time.mktime(date_time.timetuple()) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
96 else: |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
97 date = -1 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
98 return date |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
99 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
100 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
101 class Create(EventBase, base.CommandBase): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
102 def __init__(self, host): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
103 super(Create, self).__init__(host, 'create', use_pubsub_node_req=True, help=_('create or replace event')) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
104 EventBase.__init__(self) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
105 self.need_loop=True |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
106 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
107 def eventCreateCb(self, node): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
108 self.disp(_(u'Event created successfuly on node {node}').format(node=node)) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
109 self.host.quit() |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
110 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
111 def start(self): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
112 fields = self.parseFields() |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
113 date = self.parseDate() |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
114 self.host.bridge.eventCreate( |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
115 date, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
116 fields, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
117 self.args.service, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
118 self.args.node, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
119 self.args.id, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
120 self.profile, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
121 callback=self.eventCreateCb, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
122 errback=partial(self.errback, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
123 msg=_(u"can't create event: {}"), |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
124 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
125 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
126 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
127 class Modify(EventBase, base.CommandBase): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
128 def __init__(self, host): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
129 super(Modify, self).__init__(host, 'modify', use_pubsub_node_req=True, help=_('modify an existing event')) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
130 EventBase.__init__(self) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
131 self.need_loop=True |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
132 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
133 def start(self): |
2284
4fd010f29f99
jp (blog, event): added checkURI to some command to be able to enter a xmpp: uri as argument
Goffi <goffi@goffi.org>
parents:
2283
diff
changeset
|
134 common.checkURI(self.args) |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
135 fields = self.parseFields() |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
136 date = 0 if not self.args.date else self.parseDate() |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
137 self.host.bridge.eventModify( |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
138 self.args.service, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
139 self.args.node, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
140 self.args.id, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
141 date, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
142 fields, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
143 self.profile, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
144 callback=self.host.quit, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
145 errback=partial(self.errback, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
146 msg=_(u"can't update event data: {}"), |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
147 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
148 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
149 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
150 class InviteeGet(base.CommandBase): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
151 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
152 def __init__(self, host): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
153 base.CommandBase.__init__(self, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
154 host, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
155 'get', |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
156 use_output=C.OUTPUT_DICT, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
157 use_pubsub_node_req=True, |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
158 use_verbose=True, |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 help=_(u'get event attendance')) |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 self.need_loop=True |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 def add_parser_options(self): |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 pass |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
165 def eventInviteeGetCb(self, event_data): |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 self.output(event_data) |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 self.host.quit() |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 def start(self): |
2299
a3cd2ac25d58
jp (event): added checkURI to InviteeGet and InviteeSet
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
170 common.checkURI(self.args) |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
171 self.host.bridge.eventInviteeGet( |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 self.args.service, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 self.args.node, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 self.profile, |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
175 callback=self.eventInviteeGetCb, |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 errback=partial(self.errback, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 msg=_(u"can't get event data: {}"), |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
181 class InviteeSet(base.CommandBase): |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 def __init__(self, host): |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
183 super(InviteeSet, self).__init__(host, 'set', use_output=C.OUTPUT_DICT, use_pubsub_node_req=True, help=_('set event attendance')) |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 self.need_loop=True |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 def add_parser_options(self): |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set")) |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 def start(self): |
2299
a3cd2ac25d58
jp (event): added checkURI to InviteeGet and InviteeSet
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
191 common.checkURI(self.args) |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 fields = dict(self.args.fields) if self.args.fields else {} |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
193 self.host.bridge.eventInviteeSet( |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 self.args.service, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 self.args.node, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 fields, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 self.profile, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 callback=self.host.quit, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 errback=partial(self.errback, |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 msg=_(u"can't set event data: {}"), |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
204 class InviteesList(base.CommandBase): |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
205 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
206 def __init__(self, host): |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
207 extra_outputs = {'default': self.default_output} |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
208 base.CommandBase.__init__(self, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
209 host, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
210 'list', |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
211 use_output=C.OUTPUT_DICT_DICT, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
212 extra_outputs=extra_outputs, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
213 use_pubsub_node_req=True, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
214 use_verbose=True, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
215 help=_(u'get event attendance')) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
216 self.need_loop=True |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
217 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
218 def add_parser_options(self): |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
219 self.parser.add_argument('-m', '--missing', action='store_true', help=_(u'show missing people (invited but no R.S.V.P. so far)')) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
220 self.parser.add_argument('-R', '--no-rsvp', action='store_true', help=_(u"don't show people which gave R.S.V.P.")) |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
221 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
222 def _attend_filter(self, attend): |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
223 if attend == u'yes': |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
224 attend_color = C.A_SUCCESS |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
225 elif attend == u'no': |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
226 attend_color = C.A_FAILURE |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
227 else: |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
228 attend_color = A.FG_WHITE |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
229 return A.color(attend_color, attend) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
230 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
231 def _guests_filter(self, guests): |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
232 return u'(' + unicode(guests) + ')' if guests else u'' |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
233 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
234 def default_output(self, event_data): |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
235 data = [] |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
236 attendees_yes = 0 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
237 attendees_maybe = 0 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
238 attendees_no = 0 |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
239 attendees_missing = 0 |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
240 guests = 0 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
241 guests_maybe = 0 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
242 for jid_, jid_data in event_data.iteritems(): |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
243 jid_data[u'jid'] = jid_ |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
244 try: |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
245 guests_int = int(jid_data['guests']) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
246 except (ValueError, KeyError): |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
247 pass |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
248 attend = jid_data.get(u'attend',u'') |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
249 if attend == 'yes': |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
250 attendees_yes += 1 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
251 guests += guests_int |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
252 elif attend == 'maybe': |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
253 attendees_maybe += 1 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
254 guests_maybe += guests_int |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
255 elif attend == 'no': |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
256 attendees_no += 1 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
257 jid_data[u'guests'] = '' |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
258 else: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
259 attendees_missing += 1 |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
260 jid_data[u'guests'] = '' |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
261 data.append(jid_data) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
262 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
263 show_table = OUTPUT_OPT_TABLE in self.args.output_opts |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
264 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
265 table = common.Table.fromDict(self.host, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
266 data, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
267 (u'nick',) + ((u'jid',) if self.host.verbosity else ()) + (u'attend', 'guests'), |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
268 headers=None, |
2301
137ed5fbcbfd
jp (event/invitee/list): don't add a space after nick and jid when a table is displayed
Goffi <goffi@goffi.org>
parents:
2300
diff
changeset
|
269 filters = { u'nick': A.color(C.A_HEADER, u'{}' if show_table else u'{} '), |
137ed5fbcbfd
jp (event/invitee/list): don't add a space after nick and jid when a table is displayed
Goffi <goffi@goffi.org>
parents:
2300
diff
changeset
|
270 u'jid': u'{}' if show_table else u'{} ', |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
271 u'attend': self._attend_filter, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
272 u'guests': u'{}' if show_table else self._guests_filter, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
273 }, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
274 defaults = { u'nick': u'', |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
275 u'attend': u'', |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
276 u'guests': 1 |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
277 } |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
278 ) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
279 if show_table: |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
280 table.display() |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
281 else: |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
282 table.display_blank(show_header=False, col_sep=u'') |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
283 |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
284 if not self.args.no_rsvp: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
285 self.disp(u'') |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
286 self.disp(A.color( |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
287 C.A_SUBHEADER, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
288 _(u'Attendees: '), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
289 A.RESET, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
290 unicode(len(data)), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
291 _(u' ('), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
292 C.A_SUCCESS, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
293 _(u'yes: '), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
294 unicode(attendees_yes), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
295 A.FG_WHITE, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
296 _(u', maybe: '), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
297 unicode(attendees_maybe), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
298 u', ', |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
299 C.A_FAILURE, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
300 _(u'no: '), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
301 unicode(attendees_no), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
302 A.RESET, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
303 u')' |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
304 )) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
305 self.disp(A.color(C.A_SUBHEADER, _(u'confirmed guests: '), A.RESET, unicode(guests))) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
306 self.disp(A.color(C.A_SUBHEADER, _(u'unconfirmed guests: '), A.RESET, unicode(guests_maybe))) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
307 self.disp(A.color(C.A_SUBHEADER, _(u'total: '), A.RESET, unicode(guests+guests_maybe))) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
308 if attendees_missing: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
309 self.disp('') |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
310 self.disp(A.color(C.A_SUBHEADER, _(u'missing people (no reply): '), A.RESET, unicode(attendees_missing))) |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
311 |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
312 def eventInviteesListCb(self, event_data, prefilled_data): |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
313 """fill nicknames and keep only requested people |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
314 |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
315 @param event_data(dict): R.S.V.P. answers |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
316 @param prefilled_data(dict): prefilled data with all people |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
317 only filled if --missing is used |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
318 """ |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
319 if self.args.no_rsvp: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
320 for jid_ in event_data: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
321 # if there is a jid in event_data |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
322 # it must be there in prefilled_data too |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
323 # so no need to check for KeyError |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
324 del prefilled_data[jid_] |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
325 else: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
326 # we replace empty dicts for existing people with R.S.V.P. data |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
327 prefilled_data.update(event_data) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
328 |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
329 # we get nicknames for everybody, make it easier for organisers |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
330 for jid_, data in prefilled_data.iteritems(): |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
331 id_data = self.host.bridge.identityGet(jid_, self.profile) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
332 data[u'nick'] = id_data.get(u'nick', u'') |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
333 |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
334 self.output(prefilled_data) |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
335 self.host.quit() |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
336 |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
337 def getList(self, prefilled_data={}): |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
338 self.host.bridge.eventInviteesList( |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
339 self.args.service, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
340 self.args.node, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
341 self.profile, |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
342 callback=partial(self.eventInviteesListCb, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
343 prefilled_data=prefilled_data), |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
344 errback=partial(self.errback, |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
345 msg=_(u"can't get event data: {}"), |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
346 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
347 |
2321
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
348 def psNodeAffiliationsGetCb(self, affiliations): |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
349 # we fill all affiliations with empty data |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
350 # answered one will be filled in eventInviteesListCb |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
351 # we only consider people with "publisher" affiliation as invited, creators are not, and members can just observe |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
352 prefilled = {jid_: {} for jid_, affiliation in affiliations.iteritems() if affiliation in (u'publisher',)} |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
353 self.getList(prefilled) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
354 |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
355 def start(self): |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
356 if self.args.no_rsvp and not self.args.missing: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
357 self.parser.error(_(u"you need to use --missing if you use --no-rsvp")) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
358 common.checkURI(self.args) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
359 if self.args.missing: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
360 self.host.bridge.psNodeAffiliationsGet( |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
361 self.args.service, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
362 self.args.node, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
363 self.profile, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
364 callback=self.psNodeAffiliationsGetCb, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
365 errback=partial(self.errback, |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
366 msg=_(u"can't get event data: {}"), |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
367 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
368 else: |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
369 self.getList() |
c2a9da96e40b
jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents:
2301
diff
changeset
|
370 |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
371 |
2288
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
372 class InviteeInvite(base.CommandBase): |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
373 |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
374 def __init__(self, host): |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
375 base.CommandBase.__init__(self, host, 'invite', use_pubsub_node_req=True, help=_(u'invite someone to the event through email')) |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
376 self.need_loop=True |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
377 |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
378 def add_parser_options(self): |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
379 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, default=u'', help=_(u"ID of the PubSub Item")) |
2291
c05000d00dbb
plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents:
2288
diff
changeset
|
380 self.parser.add_argument("-e", "--email", action="append", type=base.unicode_decoder, default=[], help='email(s) to send the invitation to') |
2288
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
381 self.parser.add_argument("-n", "--name", type=base.unicode_decoder, default='', help='name of the invitee') |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
382 self.parser.add_argument("-N", "--host-name", type=base.unicode_decoder, default='', help='name of the host') |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
383 self.parser.add_argument("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee') |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
384 self.parser.add_argument("-u", "--url", type=base.unicode_decoder, default='', help='template to construct the URL') |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
385 self.parser.add_argument("-S", "--subject", type=base.unicode_decoder, default='', help='subject of the invitation email (default: generic subject)') |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
386 self.parser.add_argument("-b", "--body", type=base.unicode_decoder, default='', help='body of the invitation email (default: generic body)') |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
387 |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
388 def start(self): |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
389 common.checkURI(self.args) |
2291
c05000d00dbb
plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents:
2288
diff
changeset
|
390 email = self.args.email[0] if self.args.email else None |
c05000d00dbb
plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents:
2288
diff
changeset
|
391 emails_extra = self.args.email[1:] |
2288
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
392 |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
393 self.host.bridge.eventInvite( |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
394 self.args.service, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
395 self.args.node, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
396 self.args.item, |
2291
c05000d00dbb
plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents:
2288
diff
changeset
|
397 email, |
c05000d00dbb
plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents:
2288
diff
changeset
|
398 emails_extra, |
2288
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
399 self.args.name, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
400 self.args.host_name, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
401 self.args.lang, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
402 self.args.url, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
403 self.args.subject, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
404 self.args.body, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
405 self.args.profile, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
406 callback=self.host.quit, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
407 errback=partial(self.errback, |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
408 msg=_(u"can't create invitation: {}"), |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
409 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
410 |
f4d8d83a50e2
jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents:
2284
diff
changeset
|
411 |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
412 class Invitee(base.CommandBase): |
2300
173d56315529
jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents:
2299
diff
changeset
|
413 subcommands = (InviteeGet, InviteeSet, InviteesList, InviteeInvite) |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
414 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
415 def __init__(self, host): |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
416 super(Invitee, self).__init__(host, 'invitee', use_profile=False, help=_(u'manage invities')) |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
417 |
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
418 |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
419 class Event(base.CommandBase): |
2244
9d49e66bdbf2
jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents:
2236
diff
changeset
|
420 subcommands = (Get, Create, Modify, Invitee) |
2236
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
421 |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
422 def __init__(self, host): |
4b1873ce6b61
jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
423 super(Event, self).__init__(host, 'event', use_profile=False, help=_('event management')) |