annotate sat_frontends/jp/cmd_event.py @ 2676:da8f3ac86845

template: overriden get_template to always have full template name: Environment.get_template has been overriden to have always full template name (i.e. template with (site/theme) prefix or absolute template). This is needed to correctly handle cache, so "base/base.html" is converted to "(some_site/some_theme)base/base.html" and won't conflict with an other theme "base/base.html".
author Goffi <goffi@goffi.org>
date Tue, 18 Sep 2018 20:59:34 +0200
parents 56f94936df1e
children 003b8b4b56a7
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
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
33 OUTPUT_OPT_TABLE = u"table"
2300
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 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
40 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
41 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
42 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
43 "get",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
44 use_output=C.OUTPUT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
45 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
46 pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
47 use_verbose=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
48 help=_(u"get event data"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
49 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
50 self.need_loop = 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
51
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 def add_parser_options(self):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
53 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
54
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 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
56 event_date, event_data = result
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
57 event_data["date"] = event_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
58 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
59 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
60
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 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
62 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
63 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
64 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
65 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
66 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
67 callback=self.eventInviteeGetCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
68 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
69 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
70 msg=_(u"can't get event data: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
71 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
72 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
73 )
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
74
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
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 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
77 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
78 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
79 "-i",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
80 "--id",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
81 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
82 default=u"",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
83 help=_(u"ID of the PubSub Item"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
84 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
85 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
86 "-d", "--date", type=unicode, help=_(u"date of the event")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
87 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
88 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
89 "-f",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
90 "--field",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
91 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
92 action="append",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
93 nargs=2,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
94 dest="fields",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
95 metavar=(u"KEY", u"VALUE"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
96 help=_(u"configuration field to set"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
97 )
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
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 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
100 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
101
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 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
103 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
104 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
105 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
106 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
107 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
108 date_time = du_parser.parse(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
109 self.args.date, dayfirst=not (u"-" in self.args.date)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
110 )
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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120
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
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 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
123 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
124 super(Create, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
125 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
126 "create",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
127 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
128 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
129 help=_("create or replace event"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
130 )
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
131 EventBase.__init__(self)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
132 self.need_loop = 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
133
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 def eventCreateCb(self, node):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
135 self.disp(_(u"Event created successfuly on node {node}").format(node=node))
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
136 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
137
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 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 callback=self.eventCreateCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
149 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
150 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
151 msg=_(u"can't create event: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
152 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
153 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
154 )
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
155
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
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 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
158 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
159 super(Modify, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
160 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
161 "modify",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
162 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
163 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
164 help=_("modify an existing event"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
165 )
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
166 EventBase.__init__(self)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
167 self.need_loop = 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
168
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 callback=self.host.quit,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
180 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
181 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
182 msg=_(u"can't update event data: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
183 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
184 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
185 )
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
186
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
187
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
188 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
189 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
190 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
191 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
192 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
193 "get",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
194 use_output=C.OUTPUT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
195 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
196 pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
197 use_verbose=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
198 help=_(u"get event attendance"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
199 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
200 self.need_loop = True
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
201
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
202 def add_parser_options(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
203 pass
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
204
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
205 def eventInviteeGetCb(self, event_data):
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
206 self.output(event_data)
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
207 self.host.quit()
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
208
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
209 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
210 self.host.bridge.eventInviteeGet(
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
211 self.args.service,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
212 self.args.node,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
213 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
214 callback=self.eventInviteeGetCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
215 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
216 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
217 msg=_(u"can't get event data: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
218 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
219 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
220 )
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
221
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
222
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
223 class InviteeSet(base.CommandBase):
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
224 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
225 super(InviteeSet, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
226 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
227 "set",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
228 use_output=C.OUTPUT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
229 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
230 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
231 help=_("set event attendance"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
232 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
233 self.need_loop = True
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
234
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
235 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
236 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
237 "-f",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
238 "--field",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
239 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
240 action="append",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
241 nargs=2,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
242 dest="fields",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
243 metavar=(u"KEY", u"VALUE"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
244 help=_(u"configuration field to set"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
245 )
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
246
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
247 def start(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
248 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
249 self.host.bridge.eventInviteeSet(
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
250 self.args.service,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
251 self.args.node,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
252 fields,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
253 self.profile,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
254 callback=self.host.quit,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
255 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
256 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
257 msg=_(u"can't set event data: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
258 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
259 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
260 )
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
261
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
262
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
263 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
264 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
265 extra_outputs = {"default": self.default_output}
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
266 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
267 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
268 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
269 "list",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
270 use_output=C.OUTPUT_DICT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
271 extra_outputs=extra_outputs,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
272 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
273 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
274 use_verbose=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
275 help=_(u"get event attendance"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
276 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
277 self.need_loop = True
2300
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 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
280 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
281 "-m",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
282 "--missing",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
283 action="store_true",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
284 help=_(u"show missing people (invited but no R.S.V.P. so far)"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
285 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
286 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
287 "-R",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
288 "--no-rsvp",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
289 action="store_true",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
290 help=_(u"don't show people which gave R.S.V.P."),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
291 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
292
2491
5895e4daae8c jp (event): added missing arg to _attend_filter
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
293 def _attend_filter(self, attend, row):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
294 if attend == u"yes":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
295 attend_color = C.A_SUCCESS
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
296 elif attend == u"no":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
297 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
298 else:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
299 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
300 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
301
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
302 def _guests_filter(self, guests):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
303 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
304
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
305 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
306 data = []
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
307 attendees_yes = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
308 attendees_maybe = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
309 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
310 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
311 guests = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
312 guests_maybe = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
313 for jid_, jid_data in event_data.iteritems():
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
314 jid_data[u"jid"] = jid_
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
315 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
316 guests_int = int(jid_data["guests"])
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
317 except (ValueError, KeyError):
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
318 pass
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
319 attend = jid_data.get(u"attend", u"")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
320 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
321 attendees_yes += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
322 guests += guests_int
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
323 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
324 attendees_maybe += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
325 guests_maybe += guests_int
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
326 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
327 attendees_no += 1
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
328 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
329 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
330 attendees_missing += 1
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
331 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
332 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
333
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
334 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
335
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
336 table = common.Table.fromDict(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
337 self.host,
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
338 data,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
339 (u"nick",)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
340 + ((u"jid",) if self.host.verbosity else ())
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
341 + (u"attend", "guests"),
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
342 headers=None,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
343 filters={
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
344 u"nick": A.color(C.A_HEADER, u"{}" if show_table else u"{} "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
345 u"jid": u"{}" if show_table else u"{} ",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
346 u"attend": self._attend_filter,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
347 u"guests": u"{}" if show_table else self._guests_filter,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
348 },
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
349 defaults={u"nick": u"", u"attend": u"", u"guests": 1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
350 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
351 if show_table:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
352 table.display()
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
353 else:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
354 table.display_blank(show_header=False, col_sep=u"")
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
355
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
356 if not self.args.no_rsvp:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
357 self.disp(u"")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
358 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
359 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
360 C.A_SUBHEADER,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
361 _(u"Attendees: "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
362 A.RESET,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
363 unicode(len(data)),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
364 _(u" ("),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
365 C.A_SUCCESS,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
366 _(u"yes: "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
367 unicode(attendees_yes),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
368 A.FG_WHITE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
369 _(u", maybe: "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
370 unicode(attendees_maybe),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
371 u", ",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
372 C.A_FAILURE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
373 _(u"no: "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
374 unicode(attendees_no),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
375 A.RESET,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
376 u")",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
377 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
378 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
379 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
380 A.color(C.A_SUBHEADER, _(u"confirmed guests: "), A.RESET, unicode(guests))
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
381 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
382 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
383 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
384 C.A_SUBHEADER,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
385 _(u"unconfirmed guests: "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
386 A.RESET,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
387 unicode(guests_maybe),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
388 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
389 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
390 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
391 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
392 C.A_SUBHEADER, _(u"total: "), A.RESET, unicode(guests + guests_maybe)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
393 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
394 )
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
395 if attendees_missing:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
396 self.disp("")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
397 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
398 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
399 C.A_SUBHEADER,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
400 _(u"missing people (no reply): "),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
401 A.RESET,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
402 unicode(attendees_missing),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
403 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
404 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
405
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
406 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
407 """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
408
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
409 @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
410 @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
411 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
412 """
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
413 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
414 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
415 # 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
416 # 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
417 # 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
418 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
419 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
420 # 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
421 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
422
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
423 # 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
424 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
425 id_data = self.host.bridge.identityGet(jid_, self.profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
426 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
427
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
428 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
429 self.host.quit()
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
430
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
431 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
432 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
433 self.args.service,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
434 self.args.node,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
435 self.profile,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
436 callback=partial(self.eventInviteesListCb, prefilled_data=prefilled_data),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
437 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
438 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
439 msg=_(u"can't get event data: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
440 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
441 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
442 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
443
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
444 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
445 # 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
446 # 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
447 # we only consider people with "publisher" affiliation as invited, creators are not, and members can just observe
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
448 prefilled = {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
449 jid_: {}
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
450 for jid_, affiliation in affiliations.iteritems()
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
451 if affiliation in (u"publisher",)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
452 }
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
453 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
454
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
455 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
456 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
457 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
458 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
459 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
460 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
461 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
462 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
463 callback=self.psNodeAffiliationsGetCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
464 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
465 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
466 msg=_(u"can't get event data: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
467 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
468 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
469 )
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
470 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
471 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
472
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
473
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
474 class InviteeInvite(base.CommandBase):
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
475 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
476 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
477 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
478 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
479 "invite",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
480 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
481 pubsub_flags={C.NODE, C.SINGLE_ITEM},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
482 help=_(u"invite someone to the event through email"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
483 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
484 self.need_loop = True
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
485
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
486 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
487 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
488 "-e",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
489 "--email",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
490 action="append",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
491 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
492 default=[],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
493 help="email(s) to send the invitation to",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
494 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
495 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
496 "-N",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
497 "--name",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
498 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
499 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
500 help="name of the invitee",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
501 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
502 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
503 "-H",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
504 "--host-name",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
505 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
506 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
507 help="name of the host",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
508 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
509 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
510 "-l",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
511 "--lang",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
512 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
513 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
514 help="main language spoken by the invitee",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
515 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
516 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
517 "-U",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
518 "--url-template",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
519 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
520 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
521 help="template to construct the URL",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
522 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
523 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
524 "-S",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
525 "--subject",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
526 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
527 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
528 help="subject of the invitation email (default: generic subject)",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
529 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
530 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
531 "-b",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
532 "--body",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
533 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
534 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
535 help="body of the invitation email (default: generic body)",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
536 )
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
537
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
538 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
539 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
540 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
541
2616
1cc88adb5142 plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents: 2614
diff changeset
542 self.host.bridge.eventInviteByEmail(
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
543 self.args.service,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
544 self.args.node,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
545 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
546 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
547 emails_extra,
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
548 self.args.name,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
549 self.args.host_name,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
550 self.args.lang,
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
551 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
552 self.args.subject,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
553 self.args.body,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
554 self.args.profile,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
555 callback=self.host.quit,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
556 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
557 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
558 msg=_(u"can't create invitation: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
559 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
560 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
561 )
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
562
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
563
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
564 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
565 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
566
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
567 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
568 super(Invitee, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
569 host, "invitee", use_profile=False, help=_(u"manage invities")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
570 )
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
571
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
572
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
573 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
574 subcommands = (Get, Create, Modify, Invitee)
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
575
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
576 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
577 super(Event, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
578 host, "event", use_profile=False, help=_("event management")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
579 )