|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
# Copyright (C) 2012-2018 RhodeCode GmbH
|
|
|
#
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
# it under the terms of the GNU Affero General Public License, version 3
|
|
|
# (only), as published by the Free Software Foundation.
|
|
|
#
|
|
|
# This program 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 General Public License for more details.
|
|
|
#
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
#
|
|
|
# This program is dual-licensed. If you wish to learn more about the
|
|
|
# RhodeCode Enterprise Edition, including its added features, Support services,
|
|
|
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
|
|
|
|
|
import colander
|
|
|
from rhodecode.translation import _
|
|
|
|
|
|
|
|
|
class IntegrationTypeBase(object):
|
|
|
""" Base class for IntegrationType plugins """
|
|
|
is_dummy = False
|
|
|
description = ''
|
|
|
|
|
|
@classmethod
|
|
|
def icon(cls):
|
|
|
return '''
|
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
<svg
|
|
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
|
xmlns:cc="http://creativecommons.org/ns#"
|
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
|
xmlns:svg="http://www.w3.org/2000/svg"
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
|
xmlns:inkscape="http://setwww.inkscape.org/namespaces/inkscape"
|
|
|
viewBox="0 -256 1792 1792"
|
|
|
id="svg3025"
|
|
|
version="1.1"
|
|
|
inkscape:version="0.48.3.1 r9886"
|
|
|
width="100%"
|
|
|
height="100%"
|
|
|
sodipodi:docname="cog_font_awesome.svg">
|
|
|
<metadata
|
|
|
id="metadata3035">
|
|
|
<rdf:RDF>
|
|
|
<cc:Work
|
|
|
rdf:about="">
|
|
|
<dc:format>image/svg+xml</dc:format>
|
|
|
<dc:type
|
|
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
|
</cc:Work>
|
|
|
</rdf:RDF>
|
|
|
</metadata>
|
|
|
<defs
|
|
|
id="defs3033" />
|
|
|
<sodipodi:namedview
|
|
|
pagecolor="#ffffff"
|
|
|
bordercolor="#666666"
|
|
|
borderopacity="1"
|
|
|
objecttolerance="10"
|
|
|
gridtolerance="10"
|
|
|
guidetolerance="10"
|
|
|
inkscape:pageopacity="0"
|
|
|
inkscape:pageshadow="2"
|
|
|
inkscape:window-width="640"
|
|
|
inkscape:window-height="480"
|
|
|
id="namedview3031"
|
|
|
showgrid="false"
|
|
|
inkscape:zoom="0.13169643"
|
|
|
inkscape:cx="896"
|
|
|
inkscape:cy="896"
|
|
|
inkscape:window-x="0"
|
|
|
inkscape:window-y="25"
|
|
|
inkscape:window-maximized="0"
|
|
|
inkscape:current-layer="svg3025" />
|
|
|
<g
|
|
|
transform="matrix(1,0,0,-1,121.49153,1285.4237)"
|
|
|
id="g3027">
|
|
|
<path
|
|
|
d="m 1024,640 q 0,106 -75,181 -75,75 -181,75 -106,0 -181,-75 -75,-75 -75,-181 0,-106 75,-181 75,-75 181,-75 106,0 181,75 75,75 75,181 z m 512,109 V 527 q 0,-12 -8,-23 -8,-11 -20,-13 l -185,-28 q -19,-54 -39,-91 35,-50 107,-138 10,-12 10,-25 0,-13 -9,-23 -27,-37 -99,-108 -72,-71 -94,-71 -12,0 -26,9 l -138,108 q -44,-23 -91,-38 -16,-136 -29,-186 -7,-28 -36,-28 H 657 q -14,0 -24.5,8.5 Q 622,-111 621,-98 L 593,86 q -49,16 -90,37 L 362,16 Q 352,7 337,7 323,7 312,18 186,132 147,186 q -7,10 -7,23 0,12 8,23 15,21 51,66.5 36,45.5 54,70.5 -27,50 -41,99 L 29,495 Q 16,497 8,507.5 0,518 0,531 v 222 q 0,12 8,23 8,11 19,13 l 186,28 q 14,46 39,92 -40,57 -107,138 -10,12 -10,24 0,10 9,23 26,36 98.5,107.5 72.5,71.5 94.5,71.5 13,0 26,-10 l 138,-107 q 44,23 91,38 16,136 29,186 7,28 36,28 h 222 q 14,0 24.5,-8.5 Q 914,1391 915,1378 l 28,-184 q 49,-16 90,-37 l 142,107 q 9,9 24,9 13,0 25,-10 129,-119 165,-170 7,-8 7,-22 0,-12 -8,-23 -15,-21 -51,-66.5 -36,-45.5 -54,-70.5 26,-50 41,-98 l 183,-28 q 13,-2 21,-12.5 8,-10.5 8,-23.5 z"
|
|
|
id="path3029"
|
|
|
inkscape:connector-curvature="0"
|
|
|
style="fill:currentColor" />
|
|
|
</g>
|
|
|
</svg>
|
|
|
'''
|
|
|
|
|
|
def __init__(self, settings):
|
|
|
"""
|
|
|
:param settings: dict of settings to be used for the integration
|
|
|
"""
|
|
|
self.settings = settings
|
|
|
|
|
|
def settings_schema(self):
|
|
|
"""
|
|
|
A colander schema of settings for the integration type
|
|
|
"""
|
|
|
return colander.Schema()
|
|
|
|
|
|
|
|
|
class EEIntegration(IntegrationTypeBase):
|
|
|
description = 'Integration available in RhodeCode EE edition.'
|
|
|
is_dummy = True
|
|
|
|
|
|
def __init__(self, name, key, settings=None):
|
|
|
self.display_name = name
|
|
|
self.key = key
|
|
|
super(EEIntegration, self).__init__(settings)
|
|
|
|
|
|
|
|
|
# Helpers
|
|
|
|
|
|
def get_auth(settings):
|
|
|
from requests.auth import HTTPBasicAuth
|
|
|
username = settings.get('username')
|
|
|
password = settings.get('password')
|
|
|
if username and password:
|
|
|
return HTTPBasicAuth(username, password)
|
|
|
return None
|
|
|
|