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