Skip to content

Commit

Permalink
increase max chars limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Oct 5, 2018
1 parent 17a1a99 commit a9ca0a3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
18 changes: 14 additions & 4 deletions ui/src/components/CreateMentorProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
</v-flex>
<v-flex xs12>
<v-textarea prepend-icon="fa-info-circle" v-model="profile.about_me" name="aboutme"
:rules="[rules.required]" label="About me"/>
:rules="[rules.required, rules.length]" :counter="1536" label="About me"/>
</v-flex>
<v-flex xs12>
<v-textarea prepend-icon="fa-clock" v-model="profile.past_experience" name="pastexperiences"
:rules="[rules.required]" label="Past Experiences" hint="Cannot be changed later!"/>
:rules="[rules.required, rules.length]" label="Past Experiences" :counter="1536"
hint="Cannot be changed later!"/>
</v-flex>
<v-flex xs12>
<v-text-field prepend-icon="fa-github" v-model="profile.github" name="github_link"
Expand Down Expand Up @@ -78,6 +79,7 @@
},
rules: {
required: value => !!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://)'
}
Expand Down Expand Up @@ -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 () {
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/MentorProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</v-flex>
<v-flex xs12>
<v-textarea prepend-icon="fa-info-circle" :value="mentorProfile.about_me" @input="setAboutMe" name="aboutMe"
:rules="[rules.required]" label="About me"></v-textarea>
:rules="[rules.required, rules.length]" :counter="1536" label="About me"></v-textarea>
</v-flex>
<v-flex xs12>
<v-text-field prepend-icon="fa-github" :value="mentorProfile.github" @input="setGithub" name="github"
Expand Down Expand Up @@ -86,6 +86,7 @@
return {
rules: {
required: value => !!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://)'
}
Expand Down
33 changes: 20 additions & 13 deletions ui/src/store/modules/mentorProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a9ca0a3

Please sign in to comment.