From a9ca0a30da11008024b4aa941751ef00ba4da53d Mon Sep 17 00:00:00 2001 From: ajatprabha Date: Fri, 5 Oct 2018 14:46:32 +0530 Subject: [PATCH] increase max chars limit --- src/account/models.py | 4 +-- ui/src/components/CreateMentorProfile.vue | 18 ++++++++++--- ui/src/components/MentorProfile.vue | 3 ++- ui/src/store/modules/mentorProfile.js | 33 ++++++++++++++--------- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/account/models.py b/src/account/models.py index 51a1297..93f1f8e 100644 --- a/src/account/models.py +++ b/src/account/models.py @@ -44,8 +44,8 @@ def __str__(self): class MentorProfile(BaseProfile): is_approved = models.BooleanField(default=False) - about_me = models.CharField(max_length=256, help_text='Add something about You.') - past_experience = models.CharField(max_length=256, help_text='Add your Past Experience') + about_me = models.CharField(max_length=1536, help_text='Add something about You.') + past_experience = models.CharField(max_length=1536, help_text='Add your Past Experience') def __str__(self): return self.user.get_full_name() diff --git a/ui/src/components/CreateMentorProfile.vue b/ui/src/components/CreateMentorProfile.vue index 42fbdb5..737f185 100644 --- a/ui/src/components/CreateMentorProfile.vue +++ b/ui/src/components/CreateMentorProfile.vue @@ -33,11 +33,12 @@ + :rules="[rules.required, rules.length]" :counter="1536" label="About me"/> + :rules="[rules.required, rules.length]" label="Past Experiences" :counter="1536" + hint="Cannot be changed later!"/> !!value || 'Required.', + length: value => (!!value && value.length <= 1536) || 'More than 1536 characters are not allowed.', phone: value => /\(?\+[0-9]{1,3}\)? ?-?[0-9]{1,3} ?-?[0-9]{3,5} ?-?[0-9]{4}( ?-?[0-9]{3})? ?(\w{1,10}\s?\d{1,6})?|([6-9][0-9]{9})/.test(value) || 'Invalid phone number.', url: value => /(http(s)?:\/\/.)(www\.)?[-a-zA-Z0-9@:%._~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_.~#?&//=]*)/g.test(value) || 'Invalid URL (include https://)' } @@ -109,8 +111,16 @@ color: 'success' }, {root: true}) this.$emit('profile_created', this.profile) - }).catch(() => console.log('Failed to create mentor profile')) - }).catch(() => console.log('Failed to update user object')) + }).catch(() => this.$store.dispatch('messages/showMessage', { + message: 'Failed to create mentor profile', + color: 'error', + timeout: 6000 + }, {root: true})) + }).catch(() => this.$store.dispatch('messages/showMessage', { + message: 'Failed to update user', + color: 'error', + timeout: 6000 + }, {root: true})) } }, mounted () { diff --git a/ui/src/components/MentorProfile.vue b/ui/src/components/MentorProfile.vue index eb593c0..03bfebc 100644 --- a/ui/src/components/MentorProfile.vue +++ b/ui/src/components/MentorProfile.vue @@ -54,7 +54,7 @@ + :rules="[rules.required, rules.length]" :counter="1536" label="About me"> !!value || 'Required.', + length: value => (!!value && value.length <= 1536) || 'More than 1536 characters are not allowed.', phone: value => /\(?\+[0-9]{1,3}\)? ?-?[0-9]{1,3} ?-?[0-9]{3,5} ?-?[0-9]{4}( ?-?[0-9]{3})? ?(\w{1,10}\s?\d{1,6})?|([6-9][0-9]{9})/.test(value) || 'Invalid phone number.', url: value => /(http(s)?:\/\/.)(www\.)?[-a-zA-Z0-9@:%._~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_.~#?&//=]*)/g.test(value) || 'Invalid URL (include https://)' } diff --git a/ui/src/store/modules/mentorProfile.js b/ui/src/store/modules/mentorProfile.js index 4201ab5..5748e44 100644 --- a/ui/src/store/modules/mentorProfile.js +++ b/ui/src/store/modules/mentorProfile.js @@ -70,19 +70,26 @@ const actions = { httpClient.patch(`/api/account/user/${state.mentorProfile.user}/`, { first_name: state.user.first_name, last_name: state.user.last_name - }) - .then(response => { - commit('SET_USER', response.data) - httpClient.patch(`/api/account/mentor-profile/${state.mentorProfile.id}/`, { - phone: state.mentorProfile.phone, - github: state.mentorProfile.github, - gender: state.mentorProfile.gender, - about_me: state.mentorProfile.about_me - }).then(response => { - commit('SET_MENTOR_PROFILE', response.data) - dispatch('messages/showMessage', {message: 'Profile updated successfully', color: 'success'}, {root: true}) - }) - }).catch(err => console.log(err)) + }).then(response => { + commit('SET_USER', response.data) + httpClient.patch(`/api/account/mentor-profile/${state.mentorProfile.id}/`, { + phone: state.mentorProfile.phone, + github: state.mentorProfile.github, + gender: state.mentorProfile.gender, + about_me: state.mentorProfile.about_me + }).then(response => { + commit('SET_MENTOR_PROFILE', response.data) + dispatch('messages/showMessage', {message: 'Profile updated successfully', color: 'success'}, {root: true}) + }).catch(() => this.$store.dispatch('messages/showMessage', { + message: 'Failed to update mentor profile', + color: 'error', + timeout: 6000 + }, {root: true})) + }).catch(() => this.$store.dispatch('messages/showMessage', { + message: 'Failed to update user', + color: 'error', + timeout: 6000 + }, {root: true})) }, setFirstName: ({commit}, firstName) => commit('SET_FIRST_NAME', firstName), setLastName: ({commit}, lastName) => commit('SET_LAST_NAME', lastName),