/usr/lib/python2.7/dist-packages/fedmsg_meta_fedora_infrastructure/nuancier.py is in python-fedmsg-meta-fedora-infrastructure 0.2.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # This file is part of fedmsg.
# Copyright (C) 2012, 2013 Red Hat, Inc.
#
# fedmsg is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# fedmsg is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with fedmsg; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Authors: Ralph Bean <rbean@redhat.com>
# Luke Macken <lmacken@redhat.com>
from fasshim import gravatar_url
from fedmsg_meta_fedora_infrastructure import BaseProcessor
class NuancierProcessor(BaseProcessor):
__name__ = "nuancier"
__description__ = "the supplemental wallpaper voting system"
__link__ = "https://apps.fedoraproject.org/nuancier/"
__icon__ = "https://apps.fedoraproject.org/img/icons/nuancier.png"
__docs__ = "https://github.com/fedora-infra/nuancier-lite"
__obj__ = "Wallpaper Elections"
def link(self, msg, **config):
if 'original_url' in msg['msg'].get('candidate', {}):
return msg['msg']['candidate']['original_url']
kind = msg['topic'].split('.')[4]
item = msg['msg']['election']['id']
return "https://apps.fedoraproject.org/nuancier/%s/%s" % (kind, item)
def subtitle(self, msg, **config):
kwargs = dict(
agent=msg['msg']['agent'],
name=msg['msg']['election']['name'],
)
if 'election.update' in msg['topic']:
tmpl = self._(
'{agent} changed the following details '
'on the "{name}" election: {details}')
kwargs['details'] = ', '.join(msg['msg']['updated'])
elif 'election.new' in msg['topic']:
tmpl = self._(
'{agent} created a new election "{name}"')
elif 'candidate.new' in msg['topic']:
tmpl = self._(
'{agent} uploaded a new candidate for the '
'"{name}" wallpaper election')
elif 'candidate.denied' in msg['topic']:
tmpl = self._(
'{agent} denied {author}\'s "{candidate}" submission to the '
'"{name}" wallpaper election')
kwargs['author'] = msg['msg']['candidate']['submitter']
kwargs['candidate'] = msg['msg']['candidate']['name']
elif 'candidate.approved' in msg['topic']:
tmpl = self._(
'{agent} approved {author}\'s "{candidate}" submission to the '
'"{name}" wallpaper election')
kwargs['author'] = msg['msg']['candidate']['submitter']
kwargs['candidate'] = msg['msg']['candidate']['name']
else:
tmpl = ''
return tmpl.format(**kwargs)
def secondary_icon(self, msg, **config):
return gravatar_url(msg['msg']['agent'])
def usernames(self, msg, **config):
users = [msg['msg']['agent']]
if 'candidate' in msg['msg']:
users.append(msg['msg']['candidate']['submitter'])
return set(users)
def objects(self, msg, **config):
kind = msg['topic'].split('.')[-2]
action = msg['topic'].split('.')[-1]
year = msg['msg']['election']['year']
name = msg['msg']['election']['name']
candidate = msg['msg'].get('candidate', {}).get('name')
tokens = [year, name, kind, action]
if candidate:
tokens.insert(2, candidate)
return set(['/'.join(map(str, tokens))])
|