annotate sat_frontends/jp/cmd_event.py @ 2614:a5b96950b81a

jp (event): fixed crash on missing item in get and inviteeGet by making it mandatory.
author Goffi <goffi@goffi.org>
date Thu, 21 Jun 2018 01:21:44 +0200
parents 26edcf3a30eb
children 1cc88adb5142
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
0046283a285d dates update
Goffi <goffi@goffi.org>
parents: 2414
diff changeset
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,
2614
a5b96950b81a jp (event): fixed crash on missing item in get and inviteeGet by making it mandatory.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
45 use_pubsub=True, pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
2236
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):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
51 pass
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):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69
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 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
72
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 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
74 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
75 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
76 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
77 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
78
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 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
80 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
81
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 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
83 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
84 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
85 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
86 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
87 try:
2247
0f3bfe89999e jp (event): don't use dayfirst for YY-MM-DD style dates
Goffi <goffi@goffi.org>
parents: 2244
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98
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 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
101 def __init__(self, host):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
102 super(Create, self).__init__(host, 'create', use_pubsub=True, pubsub_flags={C.NODE}, help=_('create or replace event'))
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
103 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
104 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
105
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 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
107 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
108 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
109
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 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124
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 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
127 def __init__(self, host):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
128 super(Modify, self).__init__(host, 'modify', use_pubsub=True, pubsub_flags={C.NODE}, help=_('modify an existing event'))
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
129 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
130 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
131
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 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146
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
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 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
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 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
151 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
152 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 '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
154 use_output=C.OUTPUT_DICT,
2614
a5b96950b81a jp (event): fixed crash on missing item in get and inviteeGet by making it mandatory.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
155 use_pubsub=True, pubsub_flags={C.NODE, C.ITEM, C.SINGLE_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
156 use_verbose=True,
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
157 help=_(u'get event attendance'))
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
158 self.need_loop=True
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
159
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
160 def add_parser_options(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
161 pass
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
162
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
163 def eventInviteeGetCb(self, event_data):
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
164 self.output(event_data)
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
165 self.host.quit()
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
166
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
167 def start(self):
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
168 self.host.bridge.eventInviteeGet(
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
169 self.args.service,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
170 self.args.node,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
171 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
172 callback=self.eventInviteeGetCb,
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
173 errback=partial(self.errback,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
174 msg=_(u"can't get event data: {}"),
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
175 exit_code=C.EXIT_BRIDGE_ERRBACK))
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
176
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
177
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
178 class InviteeSet(base.CommandBase):
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
179 def __init__(self, host):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
180 super(InviteeSet, self).__init__(host, 'set', use_output=C.OUTPUT_DICT, use_pubsub=True, pubsub_flags={C.NODE}, help=_('set event attendance'))
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
181 self.need_loop=True
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
182
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
183 def add_parser_options(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
184 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
185 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
186
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
187 def start(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
188 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
189 self.host.bridge.eventInviteeSet(
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
190 self.args.service,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
191 self.args.node,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
192 fields,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
193 self.profile,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
194 callback=self.host.quit,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
195 errback=partial(self.errback,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
196 msg=_(u"can't set event data: {}"),
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
197 exit_code=C.EXIT_BRIDGE_ERRBACK))
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
198
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
199
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
200 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
201
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
202 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
203 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
204 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
205 host,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
206 'list',
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
207 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
208 extra_outputs=extra_outputs,
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
209 use_pubsub=True, pubsub_flags={C.NODE},
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
210 use_verbose=True,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
211 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
212 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
213
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
214 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
215 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
216 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
217
2491
5895e4daae8c jp (event): added missing arg to _attend_filter
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
218 def _attend_filter(self, attend, row):
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
219 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
220 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
221 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
222 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
223 else:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
224 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
225 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
226
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
227 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
228 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
229
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
230 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
231 data = []
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
232 attendees_yes = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
233 attendees_maybe = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
234 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
235 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
236 guests = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
237 guests_maybe = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
238 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
239 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
240 try:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
241 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
242 except (ValueError, KeyError):
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
243 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
244 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
245 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
246 attendees_yes += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
247 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
248 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
249 attendees_maybe += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
250 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
251 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
252 attendees_no += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
253 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
254 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
255 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
256 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
257 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
258
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
259 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
260
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
261 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
262 data,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
263 (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
264 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
265 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
266 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
267 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
268 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
269 },
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
270 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
271 u'attend': u'',
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
272 u'guests': 1
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 )
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
275 if show_table:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
276 table.display()
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
277 else:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
278 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
279
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
280 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
281 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
282 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
283 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
284 _(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
285 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
286 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
287 _(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
288 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
289 _(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
290 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
291 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
292 _(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
293 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
294 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
295 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
296 _(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
297 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
298 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
299 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
300 ))
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 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
302 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
303 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
304 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
305 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
306 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
307
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
308 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
309 """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
310
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
311 @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
312 @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
313 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
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 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
316 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
317 # 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
318 # 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
319 # 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
320 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
321 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
322 # 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
323 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
324
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 # 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
326 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
327 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
328 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
329
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 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
331 self.host.quit()
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
332
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 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
334 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
335 self.args.service,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
336 self.args.node,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
337 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
338 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
339 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
340 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
341 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
342 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
343
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
344 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
345 # 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
346 # 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
347 # 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
348 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
349 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
350
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 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
366
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
367 class InviteeInvite(base.CommandBase):
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
368
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
369 def __init__(self, host):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
370 base.CommandBase.__init__(self, host, 'invite', use_pubsub=True, pubsub_flags={C.NODE, C.SINGLE_ITEM}, help=_(u'invite someone to the event through email'))
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
371 self.need_loop=True
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
372
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
373 def add_parser_options(self):
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
374 self.parser.add_argument("-e", "--email", action="append", type=base.unicode_decoder, default=[], help='email(s) to send the invitation to')
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
375 self.parser.add_argument("-N", "--name", type=base.unicode_decoder, default='', help='name of the invitee')
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
376 self.parser.add_argument("-H", "--host-name", type=base.unicode_decoder, default='', help='name of the host')
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
377 self.parser.add_argument("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee')
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
378 self.parser.add_argument("-U", "--url-template", type=base.unicode_decoder, default='', help='template to construct the URL')
2288
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("-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
380 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
381
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
382 def start(self):
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
383 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
384 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
385
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
386 self.host.bridge.eventInvite(
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
387 self.args.service,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
388 self.args.node,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
389 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
390 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
391 emails_extra,
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
392 self.args.name,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
393 self.args.host_name,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
394 self.args.lang,
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
395 self.args.url_template,
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
396 self.args.subject,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
397 self.args.body,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
398 self.args.profile,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
399 callback=self.host.quit,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
400 errback=partial(self.errback,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
401 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
402 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
403
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
404
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
405 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
406 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
407
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
408 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
409 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
410
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
411
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
412 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
413 subcommands = (Get, Create, Modify, Invitee)
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
414
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
415 def __init__(self, host):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
416 super(Event, self).__init__(host, 'event', use_profile=False, help=_('event management'))