Count MUC members correctly
- Pass Affiliation enum to get_uf_affiliation - Pass Role enum to get_uf_role
This commit is contained in:
parent
80e5934bb5
commit
e994b8f402
5 changed files with 20 additions and 20 deletions
|
@ -379,8 +379,8 @@ class StandardGroupChatCommands(CommandContainer):
|
||||||
|
|
||||||
for nick in nicks:
|
for nick in nicks:
|
||||||
contact = get_contact(nick)
|
contact = get_contact(nick)
|
||||||
role = helpers.get_uf_role(contact.role.value)
|
role = helpers.get_uf_role(contact.role)
|
||||||
affiliation = helpers.get_uf_affiliation(contact.affiliation.value)
|
affiliation = helpers.get_uf_affiliation(contact.affiliation)
|
||||||
self.echo("%s - %s - %s" % (nick, role, affiliation))
|
self.echo("%s - %s - %s" % (nick, role, affiliation))
|
||||||
|
|
||||||
@command('ignore', raw=True)
|
@command('ignore', raw=True)
|
||||||
|
|
|
@ -327,19 +327,19 @@ def get_uf_ask(ask):
|
||||||
|
|
||||||
def get_uf_role(role, plural=False):
|
def get_uf_role(role, plural=False):
|
||||||
''' plural determines if you get Moderators or Moderator'''
|
''' plural determines if you get Moderators or Moderator'''
|
||||||
if role == 'none':
|
if role.value == 'none':
|
||||||
role_name = Q_('?Group Chat Contact Role:None')
|
role_name = Q_('?Group Chat Contact Role:None')
|
||||||
elif role == 'moderator':
|
elif role.value == 'moderator':
|
||||||
if plural:
|
if plural:
|
||||||
role_name = _('Moderators')
|
role_name = _('Moderators')
|
||||||
else:
|
else:
|
||||||
role_name = _('Moderator')
|
role_name = _('Moderator')
|
||||||
elif role == 'participant':
|
elif role.value == 'participant':
|
||||||
if plural:
|
if plural:
|
||||||
role_name = _('Participants')
|
role_name = _('Participants')
|
||||||
else:
|
else:
|
||||||
role_name = _('Participant')
|
role_name = _('Participant')
|
||||||
elif role == 'visitor':
|
elif role.value == 'visitor':
|
||||||
if plural:
|
if plural:
|
||||||
role_name = _('Visitors')
|
role_name = _('Visitors')
|
||||||
else:
|
else:
|
||||||
|
@ -348,13 +348,13 @@ def get_uf_role(role, plural=False):
|
||||||
|
|
||||||
def get_uf_affiliation(affiliation):
|
def get_uf_affiliation(affiliation):
|
||||||
'''Get a nice and translated affilition for muc'''
|
'''Get a nice and translated affilition for muc'''
|
||||||
if affiliation == 'none':
|
if affiliation.value == 'none':
|
||||||
affiliation_name = Q_('?Group Chat Contact Affiliation:None')
|
affiliation_name = Q_('?Group Chat Contact Affiliation:None')
|
||||||
elif affiliation == 'owner':
|
elif affiliation.value == 'owner':
|
||||||
affiliation_name = _('Owner')
|
affiliation_name = _('Owner')
|
||||||
elif affiliation == 'admin':
|
elif affiliation.value == 'admin':
|
||||||
affiliation_name = _('Administrator')
|
affiliation_name = _('Administrator')
|
||||||
elif affiliation == 'member':
|
elif affiliation.value == 'member':
|
||||||
affiliation_name = _('Member')
|
affiliation_name = _('Member')
|
||||||
else: # Argl ! An unknown affiliation !
|
else: # Argl ! An unknown affiliation !
|
||||||
affiliation_name = affiliation.capitalize()
|
affiliation_name = affiliation.capitalize()
|
||||||
|
|
|
@ -1768,7 +1768,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.model[role_iter][Column.TEXT] = role_name
|
self.model[role_iter][Column.TEXT] = role_name
|
||||||
|
|
||||||
def draw_all_roles(self):
|
def draw_all_roles(self):
|
||||||
for role in ('visitor', 'participant', 'moderator'):
|
for role in (Role.VISITOR, Role.PARTICIPANT, Role.MODERATOR):
|
||||||
self.draw_role(role)
|
self.draw_role(role)
|
||||||
|
|
||||||
def _change_nick(self, new_nick: str) -> None:
|
def _change_nick(self, new_nick: str) -> None:
|
||||||
|
@ -1899,7 +1899,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
return
|
return
|
||||||
|
|
||||||
affiliation = helpers.get_uf_affiliation(
|
affiliation = helpers.get_uf_affiliation(
|
||||||
event.properties.affiliation.value)
|
event.properties.affiliation)
|
||||||
nick = event.properties.muc_nickname
|
nick = event.properties.muc_nickname
|
||||||
reason = event.properties.muc_user.reason
|
reason = event.properties.muc_user.reason
|
||||||
reason = '' if reason is None else ': {reason}'.format(reason=reason)
|
reason = '' if reason is None else ': {reason}'.format(reason=reason)
|
||||||
|
@ -1932,7 +1932,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
if event.room_jid != self.room_jid:
|
if event.room_jid != self.room_jid:
|
||||||
return
|
return
|
||||||
|
|
||||||
role = helpers.get_uf_role(event.properties.role.value)
|
role = helpers.get_uf_role(event.properties.role)
|
||||||
nick = event.properties.muc_nickname
|
nick = event.properties.muc_nickname
|
||||||
reason = event.properties.muc_user.reason
|
reason = event.properties.muc_user.reason
|
||||||
reason = '' if reason is None else ': {reason}'.format(reason=reason)
|
reason = '' if reason is None else ': {reason}'.format(reason=reason)
|
||||||
|
@ -2167,17 +2167,17 @@ class GroupchatControl(ChatControlBase):
|
||||||
contact = app.contacts.get_gc_contact(self.account,
|
contact = app.contacts.get_gc_contact(self.account,
|
||||||
self.room_jid,
|
self.room_jid,
|
||||||
nick)
|
nick)
|
||||||
role_name = helpers.get_uf_role(contact.role.value, plural=True)
|
role_name = helpers.get_uf_role(contact.role, plural=True)
|
||||||
|
|
||||||
# Create Role
|
# Create Role
|
||||||
role_iter = self.get_role_iter(contact.role.value)
|
role_iter = self.get_role_iter(contact.role)
|
||||||
if not role_iter:
|
if not role_iter:
|
||||||
icon_name = get_icon_name('closed')
|
icon_name = get_icon_name('closed')
|
||||||
ext_columns = [None] * self.nb_ext_renderers
|
ext_columns = [None] * self.nb_ext_renderers
|
||||||
row = [icon_name, contact.role.value,
|
row = [icon_name, contact.role.value,
|
||||||
'role', role_name, None] + ext_columns
|
'role', role_name, None] + ext_columns
|
||||||
role_iter = self.model.append(None, row)
|
role_iter = self.model.append(None, row)
|
||||||
self._role_refs[contact.role.value] = Gtk.TreeRowReference(
|
self._role_refs[contact.role] = Gtk.TreeRowReference(
|
||||||
self.model, self.model.get_path(role_iter))
|
self.model, self.model.get_path(role_iter))
|
||||||
|
|
||||||
# Avatar
|
# Avatar
|
||||||
|
@ -2262,7 +2262,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
del self._contact_refs[nick]
|
del self._contact_refs[nick]
|
||||||
if self.model.iter_n_children(parent_iter) == 0:
|
if self.model.iter_n_children(parent_iter) == 0:
|
||||||
role = self.model[parent_iter][Column.NICK]
|
role = self.model[parent_iter][Column.NICK]
|
||||||
del self._role_refs[role]
|
del self._role_refs[Role(role)]
|
||||||
self.model.remove(parent_iter)
|
self.model.remove(parent_iter)
|
||||||
|
|
||||||
def _message_sent(self, obj):
|
def _message_sent(self, obj):
|
||||||
|
|
|
@ -214,7 +214,7 @@ class GCTooltip():
|
||||||
|
|
||||||
# Affiliation
|
# Affiliation
|
||||||
if not contact.affiliation.is_none:
|
if not contact.affiliation.is_none:
|
||||||
uf_affiliation = helpers.get_uf_affiliation(contact.affiliation.value)
|
uf_affiliation = helpers.get_uf_affiliation(contact.affiliation)
|
||||||
uf_affiliation = \
|
uf_affiliation = \
|
||||||
_('%(owner_or_admin_or_member)s of this group chat') \
|
_('%(owner_or_admin_or_member)s of this group chat') \
|
||||||
% {'owner_or_admin_or_member': uf_affiliation}
|
% {'owner_or_admin_or_member': uf_affiliation}
|
||||||
|
|
|
@ -372,11 +372,11 @@ class VcardWindow:
|
||||||
ask_label = self.xml.get_object('ask_label')
|
ask_label = self.xml.get_object('ask_label')
|
||||||
if self.gc_contact:
|
if self.gc_contact:
|
||||||
self.xml.get_object('subscription_title_label').set_markup(Q_("?Role in Group Chat:<b>Role:</b>"))
|
self.xml.get_object('subscription_title_label').set_markup(Q_("?Role in Group Chat:<b>Role:</b>"))
|
||||||
uf_role = helpers.get_uf_role(self.gc_contact.role.value)
|
uf_role = helpers.get_uf_role(self.gc_contact.role)
|
||||||
subscription_label.set_text(uf_role)
|
subscription_label.set_text(uf_role)
|
||||||
|
|
||||||
self.xml.get_object('ask_title_label').set_markup(_("<b>Affiliation:</b>"))
|
self.xml.get_object('ask_title_label').set_markup(_("<b>Affiliation:</b>"))
|
||||||
uf_affiliation = helpers.get_uf_affiliation(self.gc_contact.affiliation.value)
|
uf_affiliation = helpers.get_uf_affiliation(self.gc_contact.affiliation)
|
||||||
ask_label.set_text(uf_affiliation)
|
ask_label.set_text(uf_affiliation)
|
||||||
else:
|
else:
|
||||||
uf_sub = helpers.get_uf_sub(self.contact.sub)
|
uf_sub = helpers.get_uf_sub(self.contact.sub)
|
||||||
|
|
Loading…
Add table
Reference in a new issue