Created
November 7, 2016 20:46
-
-
Save rhelmer/c9b8591926ad287808f8abcf39324cbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/client/ui/components/forms/AddonGroupForm.jsx b/client/ui/components/forms/AddonGroupForm.jsx | |
| index 53037c9..f091fc0 100644 | |
| --- a/client/ui/components/forms/AddonGroupForm.jsx | |
| +++ b/client/ui/components/forms/AddonGroupForm.jsx | |
| @@ -33,7 +33,7 @@ class AddonGroupForm extends React.Component { | |
| pk: pt.string, | |
| saveAddonGroup: pt.func.isRequired, | |
| saveRequest: pt.object, | |
| - syncAddonGroup: pt.func.isRequired, | |
| + syncAddonGroups: pt.func.isRequired, | |
| } | |
| componentWillMount() { | |
| @@ -52,7 +52,7 @@ class AddonGroupForm extends React.Component { | |
| render() { | |
| const { | |
| addonGroup, addons, fetchRequest, handleSubmit, saveAddonGroup, saveRequest, pk, | |
| - syncAddonGroup, | |
| + syncAddonGroups, | |
| } = this.props; | |
| const isSaving = saveRequest.loading; | |
| const saveError = saveRequest.error; | |
| @@ -91,7 +91,7 @@ class AddonGroupForm extends React.Component { | |
| </ToolbarGroup> | |
| <ToolbarGroup lastChild> | |
| <RaisedButton | |
| - onClick={syncAddonGroup} | |
| + onClick={syncAddonGroups} | |
| label="Sync" | |
| disabled={!pk} | |
| /> | |
| diff --git a/client/ui/containers/AddonGroupDetailsContainer.js b/client/ui/containers/AddonGroupDetailsContainer.js | |
| index 438e314..ea702d4 100644 | |
| --- a/client/ui/containers/AddonGroupDetailsContainer.js | |
| +++ b/client/ui/containers/AddonGroupDetailsContainer.js | |
| @@ -3,7 +3,7 @@ import { bindActionCreators } from 'redux'; | |
| import { initialize } from 'redux-form'; | |
| import { getAddonsList } from '../state/addons/selectors'; | |
| -import { createAddonGroup, syncAddonGroup, updateAddonGroup } from '../state/addonGroups/actions'; | |
| +import { createAddonGroup, syncAddonGroups, updateAddonGroup } from '../state/addonGroups/actions'; | |
| import { getAddonGroup, getRequest } from '../state/addonGroups/selectors'; | |
| @@ -45,7 +45,7 @@ function mapDispatchToProps(dispatch, { pk }) { | |
| return bindActionCreators({ | |
| initialize, | |
| saveAddonGroup, | |
| - syncAddonGroup, | |
| + syncAddonGroups, | |
| }, dispatch); | |
| } | |
| diff --git a/client/ui/state/addonGroups/actions.js b/client/ui/state/addonGroups/actions.js | |
| index d8d58c1..1df433f 100644 | |
| --- a/client/ui/state/addonGroups/actions.js | |
| +++ b/client/ui/state/addonGroups/actions.js | |
| @@ -215,7 +215,7 @@ function syncAddonGroupFailure(dispatch, requestId, error) { | |
| }); | |
| } | |
| -export function syncAddonGroup(pk) { | |
| +export function syncAddonGroups(pk) { | |
| return (dispatch, getState) => { | |
| const requestId = `sync-${pk}`; | |
| const request = getRequest(getState(), requestId); | |
| @@ -229,7 +229,7 @@ export function syncAddonGroup(pk) { | |
| requestId, | |
| }); | |
| - return apiFetch(`addon_group/${pk}/sync/`, { method: 'POST' }) | |
| + return apiFetch(`addon_group/sync/`, { method: 'POST' }) | |
| .then(() => syncAddonGroupSuccess(dispatch, requestId)) | |
| .catch(error => syncAddonGroupFailure(dispatch, requestId, error)); | |
| }; | |
| diff --git a/morgoth/addons/api/views.py b/morgoth/addons/api/views.py | |
| index d858f50..23b78de 100644 | |
| --- a/morgoth/addons/api/views.py | |
| +++ b/morgoth/addons/api/views.py | |
| @@ -84,17 +84,25 @@ class AddonGroupViewSet(ModelViewSet): | |
| return Response(status=status.HTTP_204_NO_CONTENT) | |
| - @detail_route(methods=['POST']) | |
| - def sync(self, request, *args, **kwargs): | |
| - group = self.get_object() | |
| + @list_route(methods=['POST']) | |
| + def sync(self, request): | |
| + groups = AddonGroup.objects.all() | |
| + | |
| balrog = BalrogAPI(auth=request.ldap) | |
| + # TODO remove all Morgoth-generated Balrog rules. | |
| - balrog.request('releases', method='POST', data={ | |
| - 'name': group.name, 'product': 'SystemAddons', 'blob': json.dumps(group.release_data)}) | |
| - balrog.request('rules', method='POST', data={ | |
| - 'priority': 1000, 'backgroundRate': 100, 'product': 'SystemAddons', | |
| - 'version': group.browser_version, 'mapping': group.name, | |
| - 'comment': 'Generated by Morgoth.'}) | |
| + results = [] | |
| + for group in groups: | |
| + releases_request = {'method': 'POST', 'data': { | |
| + 'name': group.name, 'product': 'SystemAddons', 'blob': json.dumps(group.release_data)}} | |
| - return Response(status=status.HTTP_204_NO_CONTENT) | |
| + rules_request = {'method': 'POST', 'data': { | |
| + 'priority': 1000, 'backgroundRate': 100, 'product': 'SystemAddons', | |
| + 'version': group.browser_version, 'mapping': group.name, | |
| + 'comment': 'Generated by Morgoth.'}} | |
| + | |
| + results.append(releases_request) | |
| + results.append(rules_request) | |
| + | |
| + return Response(results, status=status.HTTP_200_OK) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so one small thing, we need to pass a channel to this API endpoint to tell it which channel to sync. the two channels are
releaseandrelease-sysaddon(this is the QA testing channel). we then need to pass that in therules_request: