##// END OF EJS Templates
integrations-db: don't use default contructor to be consisten with other modules...
marcink -
r448:b686b009 default
parent child Browse files
Show More
@@ -179,7 +179,7 b' class IntegrationSettingsViewBase(object'
179 179
180 180 try:
181 181 valid_data = schema.deserialize(params)
182 except colander.Invalid, e:
182 except colander.Invalid as e:
183 183 # Display error message and display form again.
184 184 self.request.session.flash(
185 185 _('Errors exist when saving plugin settings. '
@@ -188,17 +188,17 b' class IntegrationSettingsViewBase(object'
188 188 return self.settings_get(errors=e.asdict(), defaults=params)
189 189
190 190 if not self.integration:
191 self.integration = Integration(
192 integration_type=self.IntegrationType.key)
191 self.integration = Integration()
192 self.integration.integration_type = self.IntegrationType.key
193 193 if self.repo:
194 194 self.integration.repo = self.repo
195 Session.add(self.integration)
195 Session().add(self.integration)
196 196
197 197 self.integration.enabled = valid_data.pop('enabled', False)
198 198 self.integration.name = valid_data.pop('name')
199 199 self.integration.settings = valid_data
200 200
201 Session.commit()
201 Session().commit()
202 202
203 203 # Display success message and redirect.
204 204 self.request.session.flash(
@@ -3500,11 +3500,6 b' class Integration(Base, BaseModel):'
3500 3500 nullable=True, unique=None, default=None)
3501 3501 repo = relationship('Repository', lazy='joined')
3502 3502
3503 def __init__(self, **kw):
3504 settings = kw.pop('settings', {})
3505 self.settings = settings
3506 super(Integration, self).__init__(**kw)
3507
3508 3503 def __repr__(self):
3509 3504 if self.repo:
3510 3505 scope = 'repo=%r' % self.repo
@@ -3512,6 +3507,3 b' class Integration(Base, BaseModel):'
3512 3507 scope = 'global'
3513 3508
3514 3509 return '<Integration(%r, %r)>' % (self.integration_type, scope)
3515
3516 def settings_as_dict(self):
3517 return json.loads(self.settings_json)
@@ -63,13 +63,13 b' class IntegrationModel(BaseModel):'
63 63
64 64 def create(self, IntegrationType, enabled, name, settings, repo=None):
65 65 """ Create an IntegrationType integration """
66 integration = Integration(
67 integration_type=IntegrationType.key,
68 settings={},
69 repo=repo,
70 enabled=enabled,
71 name=name
72 )
66 integration = Integration()
67 integration.integration_type = IntegrationType.key
68 integration.settings = {}
69 integration.repo = repo
70 integration.enabled = enabled
71 integration.name = name
72
73 73 self.sa.add(integration)
74 74 self.sa.commit()
75 75 return integration
@@ -71,11 +71,10 b' def slack_settings():'
71 71
72 72 @pytest.fixture
73 73 def slack_integration(request, app, slack_settings):
74 integration = Integration(
75 name='test slack integration',
76 enabled=True,
77 integration_type=SlackIntegrationType.key
78 )
74 integration = Integration()
75 integration.name = 'test slack integration'
76 integration.enabled = True
77 integration.integration_type = SlackIntegrationType.key
79 78 integration.settings = slack_settings
80 79 Session().add(integration)
81 80 Session().commit()
General Comments 0
You need to be logged in to leave comments. Login now