Skip to content

Commit

Permalink
Merge pull request #3225 from learningequality/hotfixes
Browse files Browse the repository at this point in the history
Master release for last 2 sprints ending 2021-07-06
  • Loading branch information
bjester authored Jul 8, 2021
2 parents 62baa46 + 5572799 commit b1fed67
Show file tree
Hide file tree
Showing 38 changed files with 431 additions and 170 deletions.
15 changes: 15 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version = 1

[[analyzers]]
name = "javascript"
enabled = true

[analyzers.meta]
plugins = ["vue"]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
20 changes: 19 additions & 1 deletion .github/workflows/frontendlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,22 @@ jobs:
yarn --frozen-lockfile
npm rebuild node-sass
- name: Run tests
run: yarn run lint-all
run: yarn run lint-all:fix
- name: Check for modified files
if: github.event.pull_request && github.event.pull_request.head.repo.full_name == github.repository
id: git-check
run: echo ::set-output name=modified::$(git diff-index --name-only HEAD)
- uses: tibdex/github-app-token@v1
if: github.event.pull_request && github.event.pull_request.head.repo.full_name == github.repository && steps.git-check.outputs.modified != ''
id: generate-token
with:
app_id: ${{ secrets.CODE_FIX_APP_ID }}
private_key: ${{ secrets.CODE_FIX_APP_PRIVATE_KEY }}
- name: Push changes
if: github.event.pull_request && github.event.pull_request.head.repo.full_name == github.repository && steps.git-check.outputs.modified != ''
run: |
git config --global user.name 'Learning Equality'
git config --global user.email 'dev@learningequality.org'
git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }}
git commit -am "Frontend linting of ${{ steps.git-check.outputs.modified }}"
git push
51 changes: 25 additions & 26 deletions contentcuration/contentcuration/db/models/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,35 +394,34 @@ def _copy(
if progress_tracker:
progress_tracker.increment(len(copied_nodes))
return copied_nodes
else:
node_copy = self._shallow_copy(
node,
target,
position,
node_copy = self._shallow_copy(
node,
target,
position,
source_channel_id,
pk,
mods,
can_edit_source_channel,
)
if progress_tracker:
progress_tracker.increment()
children = node.get_children().order_by("lft")
if excluded_descendants:
children = children.exclude(node_id__in=excluded_descendants.keys())
for child in children:
self._copy(
child,
node_copy,
"last-child",
source_channel_id,
pk,
mods,
None,
None,
excluded_descendants,
can_edit_source_channel,
batch_size,
progress_tracker=progress_tracker,
)
if progress_tracker:
progress_tracker.increment()
children = node.get_children().order_by("lft")
if excluded_descendants:
children = children.exclude(node_id__in=excluded_descendants.keys())
for child in children:
self._copy(
child,
node_copy,
"last-child",
source_channel_id,
None,
None,
excluded_descendants,
can_edit_source_channel,
batch_size,
progress_tracker=progress_tracker,
)
return [node_copy]
return [node_copy]

def _copy_tags(self, source_copy_id_map):
from contentcuration.models import ContentTag
Expand Down
17 changes: 13 additions & 4 deletions contentcuration/contentcuration/frontend/accounts/pages/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<Banner :value="!valid" error class="mb-4">
{{ registrationFailed ? $tr('registrationFailed') : $tr('errorsMessage') }}
</Banner>

<Banner :value="offline" error class="mb-4">
{{ $tr('registrationFailedOffline') }}
</Banner>
<!-- Basic information -->
<h1 class="font-weight-bold my-2 subheading">
{{ $tr('basicInformationHeader') }}
Expand Down Expand Up @@ -157,7 +159,7 @@
<p class="mb-4">
{{ $tr('contactMessage') }}
</p>
<VBtn color="primary" large type="submit">
<VBtn color="primary" large :disabled="offline" type="submit">
{{ $tr('finishButton') }}
</VBtn>
</VForm>
Expand All @@ -171,7 +173,7 @@

<script>
import { mapActions, mapGetters } from 'vuex';
import { mapActions, mapGetters, mapState } from 'vuex';
import { uses, sources } from '../constants';
import TextField from 'shared/views/form/TextField';
import EmailField from 'shared/views/form/EmailField';
Expand Down Expand Up @@ -222,6 +224,9 @@
};
},
computed: {
...mapState({
offline: state => !state.connection.online,
}),
...mapGetters('policies', ['getPolicyAcceptedData']),
passwordConfirmRules() {
return [value => (this.form.password1 === value ? true : this.$tr('passwordMatchMessage'))];
Expand Down Expand Up @@ -410,7 +415,9 @@
this.$router.push({ name: 'ActivationSent' });
})
.catch(error => {
if (error.response.status === 403) {
if (error.message === 'Network Error') {
this.$refs.top.scrollIntoView({ behavior: 'smooth' });
} else if (error.response.status === 403) {
this.emailErrors = [this.$tr('emailExistsMessage')];
} else if (error.response.status === 405) {
this.$router.push({ name: 'AccountNotActivated' });
Expand All @@ -431,6 +438,8 @@
fieldRequiredMessage: 'Field is required',
errorsMessage: 'Please fix the errors below',
registrationFailed: 'There was an error registering your account. Please try again',
registrationFailedOffline:
'You seem to be offline. Please connect to the internet to create an account.',
// Basic information strings
basicInformationHeader: 'Basic information',
Expand Down
31 changes: 27 additions & 4 deletions contentcuration/contentcuration/frontend/accounts/pages/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
justify-center
class="main pt-5"
>
<h3 class="corner">
<OfflineText indicator />
</h3>
<div>
<!-- Sign in -->
<VCard class="pa-4" style="width: 300px;margin: 0 auto;">
Expand All @@ -20,6 +23,7 @@
{{ $tr('kolibriStudio') }}
</h2>
<Banner :value="loginFailed" :text="$tr('loginFailed')" error />
<Banner :value="offline" :text="$tr('loginFailedOffline')" error />
<Banner
:value="Boolean(nextParam)"
:text="$tr('loginToProceed')"
Expand All @@ -32,7 +36,7 @@
<p>
<ActionLink :to="{ name: 'ForgotPassword' }" :text="$tr('forgotPasswordLink')" />
</p>
<VBtn block color="primary" large type="submit" :disabled="busy">
<VBtn block color="primary" large type="submit" :disabled="offline || busy">
{{ $tr('signInButton') }}
</VBtn>
<VBtn block flat color="primary" class="mt-2" :to="{ name: 'Create' }">
Expand Down Expand Up @@ -79,13 +83,14 @@

<script>
import { mapActions } from 'vuex';
import { mapActions, mapState } from 'vuex';
import EmailField from 'shared/views/form/EmailField';
import PasswordField from 'shared/views/form/PasswordField';
import Banner from 'shared/views/Banner';
import PolicyModals from 'shared/views/policies/PolicyModals';
import { policies } from 'shared/constants';
import LanguageSwitcherList from 'shared/languageSwitcher/LanguageSwitcherList';
import OfflineText from 'shared/views/OfflineText';
export default {
name: 'Main',
Expand All @@ -95,16 +100,21 @@
LanguageSwitcherList,
PasswordField,
PolicyModals,
OfflineText,
},
data() {
return {
username: '',
password: '',
loginFailed: false,
busy: false,
loginFailedOffline: false,
};
},
computed: {
...mapState({
offline: state => !state.connection.online,
}),
nextParam() {
const params = new URLSearchParams(window.location.search.substring(1));
return params.get('next');
Expand All @@ -128,14 +138,19 @@
};
return this.login(credentials)
.then(() => {
this.loginFailedOffline = false;
this.loginFailed = false;
window.location.assign(this.nextParam || window.Urls.channels());
})
.catch(err => {
this.busy = false;
if (err.response.status === 405) {
if (err.message === 'Network Error') {
this.loginFailedOffline = true;
} else if (err.response.status === 405) {
this.$router.push({ name: 'AccountNotActivated' });
} else {
this.loginFailed = true;
}
this.loginFailed = true;
});
}
return Promise.resolve();
Expand All @@ -153,6 +168,8 @@
TOSLink: 'Terms of service',
copyright: '© {year} Learning Equality',
loginToProceed: 'You must sign in to view that page',
loginFailedOffline:
'You seem to be offline. Please connect to the internet before signing in.',
},
};
Expand All @@ -174,4 +191,10 @@
content: '';
}
.corner {
position: absolute;
top: 1em;
left: 1em;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import router from '../../router';
import { uses, sources } from '../../constants';
import Create from '../Create';

const connectionStateMocks = {
$store: {
state: {
connection: {
offline: true,
},
},
},
};

const defaultData = {
first_name: 'Test',
last_name: 'User',
Expand Down Expand Up @@ -34,6 +44,7 @@ function makeWrapper(formData) {
},
},
stubs: ['PolicyModals'],
mocks: connectionStateMocks,
});
wrapper.setData({
form: {
Expand Down Expand Up @@ -87,7 +98,7 @@ describe('create', () => {
});
it('should automatically fill the email if provided in the query param', () => {
router.push({ name: 'Create', query: { email: 'newtest@test.com' } });
let wrapper = mount(Create, { router, stubs: ['PolicyModals'] });
let wrapper = mount(Create, { router, stubs: ['PolicyModals'], mocks: connectionStateMocks });
expect(wrapper.vm.form.email).toBe('newtest@test.com');
});
describe('validation', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ function makeWrapper() {
let wrapper = mount(Main, {
router,
stubs: ['GlobalSnackbar', 'PolicyModals'],
mocks: {
$store: {
state: {
connection: {
online: true,
},
},
},
},
});
wrapper.setMethods({
login: data => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ContentKinds = new Set([
'slideshow',
'topic',
'video',
'zim',
]);

export default ContentKinds;
Expand All @@ -23,4 +24,5 @@ export const ContentKindsNames = {
SLIDESHOW: 'slideshow',
TOPIC: 'topic',
VIDEO: 'video',
ZIM: 'zim',
};
Loading

0 comments on commit b1fed67

Please sign in to comment.