fix: codacy linting issues

This commit is contained in:
scmmishra
2019-04-09 12:57:56 +05:30
parent abb35ad308
commit bae2d669b5
4 changed files with 32 additions and 35 deletions

View File

@@ -13,7 +13,7 @@ class Quiz(Document):
try: try:
if len(frappe.get_all("Quiz Activity", {'enrollment': enrollment.name, 'quiz': quiz_name})) >= self.max_attempts: if len(frappe.get_all("Quiz Activity", {'enrollment': enrollment.name, 'quiz': quiz_name})) >= self.max_attempts:
frappe.throw('Maximum attempts reached!') frappe.throw('Maximum attempts reached!')
except: except Exception as e:
pass pass

View File

@@ -1,15 +1,15 @@
frappe.ready(() => { frappe.ready(() => {
frappe.provide('lms'); frappe.provide('lms');
lms.call = (method, args) => { lms.call = (method, args) => {
const method_path = 'erpnext.www.lms.' + method; const method_path = 'erpnext.www.lms.' + method;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
return frappe.call({ return frappe.call({
method: method_path, method: method_path,
args, args,
}) })
.then(r => resolve(r.message)) .then(r => resolve(r.message))
.fail(reject) .fail(reject);
}); });
} };
}); });

View File

@@ -1,26 +1,25 @@
import Vue from 'vue/dist/vue.js'; import Vue from 'vue/dist/vue.js';
import VueRouter from 'vue-router/dist/vue-router.js' import VueRouter from 'vue-router/dist/vue-router.js';
import moment from 'moment/min/moment.min.js' import moment from 'moment/min/moment.min.js';
import lmsRoot from "./lmsRoot.vue"; import lmsRoot from "./lmsRoot.vue";
import routes from './routes'; import routes from './routes';
import './call'; import './call';
Vue.use(VueRouter) Vue.use(VueRouter);
var store = { var store = {
enrolledPrograms: [], enrolledPrograms: [],
enrolledCourses: [] enrolledCourses: []
} };
// let profile_page = `<a class="dropdown-item" href="/lms#/Profile" rel="nofollow"> LMS Profile </a>` // let profile_page = `<a class="dropdown-item" href="/lms#/Profile" rel="nofollow"> LMS Profile </a>`
// document.querySelector('#website-post-login > ul').innerHTML += profile_page // document.querySelector('#website-post-login > ul').innerHTML += profile_page
frappe.ready(() => { frappe.ready(() => {
frappe.provide('lms') frappe.provide('lms');
// frappe.utils.make_event_emitter(lms);
lms.moment = moment lms.moment = moment;
lms.store = new Vue({ lms.store = new Vue({
data: store, data: store,
@@ -28,26 +27,24 @@ frappe.ready(() => {
updateEnrolledPrograms() { updateEnrolledPrograms() {
if(this.checkLogin()) { if(this.checkLogin()) {
lms.call("get_program_enrollments").then(data => { lms.call("get_program_enrollments").then(data => {
this.enrolledPrograms = data this.enrolledPrograms = data;
}); });
if (lms.debug) console.log('Updated Enrolled Programs', this.enrolledPrograms)
} }
}, },
updateEnrolledCourses() { updateEnrolledCourses() {
if(this.checkLogin()) { if(this.checkLogin()) {
lms.call("get_all_course_enrollments").then(data => { lms.call("get_all_course_enrollments").then(data => {
this.enrolledCourses = data this.enrolledCourses = data;
}) })
if (lms.debug) console.log('Updated Enrolled Courses', this.enrolledCourses)
} }
}, },
checkLogin() { checkLogin() {
return frappe.is_user_logged_in() return frappe.is_user_logged_in();
}, },
updateState() { updateState() {
this.checkLogin() this.checkLogin();
this.updateEnrolledPrograms() this.updateEnrolledPrograms();
this.updateEnrolledCourses() this.updateEnrolledCourses();
}, },
checkProgramEnrollment(programName) { checkProgramEnrollment(programName) {
if(this.checkLogin()){ if(this.checkLogin()){
@@ -80,6 +77,6 @@ frappe.ready(() => {
}); });
lms.view.$router.afterEach((to, from) => { lms.view.$router.afterEach((to, from) => {
window.scrollTo(0,0) window.scrollTo(0,0)
}) });
lms.debug = true lms.debug = true
}) });

View File

@@ -50,7 +50,7 @@ const routes = [{
name: 'signup', name: 'signup',
path: '/Signup', path: '/Signup',
beforeEnter(to, from, next) { beforeEnter(to, from, next) {
window.location = window.location.origin.toString() + '/login#signup' window.location = window.location.origin.toString() + '/login#signup';
}, },
component: Home, component: Home,
props: true props: true
@@ -59,7 +59,7 @@ const routes = [{
name: 'login', name: 'login',
path: '/Login', path: '/Login',
beforeEnter(to, from, next) { beforeEnter(to, from, next) {
window.location = window.location.origin.toString() + '/login#login' window.location = window.location.origin.toString() + '/login#login';
}, },
component: Home, component: Home,
props: true props: true
@@ -68,7 +68,7 @@ const routes = [{
name: 'logout', name: 'logout',
path: '/Logout', path: '/Logout',
beforeEnter(to, from, next) { beforeEnter(to, from, next) {
window.location = window.location.origin.toString() + '/?cmd=web_logout' window.location = window.location.origin.toString() + '/?cmd=web_logout';
}, },
component: Home, component: Home,
props: true props: true
@@ -82,9 +82,9 @@ const routes = [{
if (!lms.store.checkLogin()) { if (!lms.store.checkLogin()) {
next({ next({
name: 'home' name: 'home'
}) });
} else { } else {
next() next();
} }
} }
}]; }];