Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenJob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mai Hoang Thai Ha
VenJob
Commits
afd86273
Commit
afd86273
authored
Aug 24, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cv field to user, click to download; validate: cv, register, edit info
parent
dec3d955
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
10 deletions
+79
-10
app/controllers/application_controller.rb
+1
-1
app/models/user.rb
+20
-2
app/views/users/passwords/new.html.slim
+30
-0
app/views/users/registrations/edit.html.slim
+6
-0
app/views/users/registrations/infomation.html.slim
+13
-5
app/views/users/sessions/new.html.slim
+0
-1
app/views/users/show.html.slim
+9
-1
No files found.
app/controllers/application_controller.rb
View file @
afd86273
...
@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
...
@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
def
configure_permitted_parameters
def
configure_permitted_parameters
devise_parameter_sanitizer
.
permit
:sign_up
,
keys:
%i[name address phone email password]
devise_parameter_sanitizer
.
permit
:sign_up
,
keys:
%i[name address phone email password]
devise_parameter_sanitizer
.
permit
:account_update
,
keys:
%i[name email address phone password]
devise_parameter_sanitizer
.
permit
:account_update
,
keys:
%i[name email address phone password
cv
]
end
end
private
private
...
...
app/models/user.rb
View file @
afd86273
class
User
<
ApplicationRecord
class
User
<
ApplicationRecord
# Include default devise modules. Others available are:
ACCEPT_CONTENT_TYPE
=
'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
.
freeze
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise
:invitable
,
:database_authenticatable
,
:registerable
,
devise
:invitable
,
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:validatable
,
:confirmable
:recoverable
,
:rememberable
,
:validatable
,
:confirmable
has_many
:apply_jobs
,
dependent: :destroy
has_many
:apply_jobs
,
dependent: :destroy
has_many
:favorite_jobs
,
dependent: :destroy
has_many
:favorite_jobs
,
dependent: :destroy
has_many
:history_jobs
,
dependent: :destroy
has_many
:history_jobs
,
dependent: :destroy
has_one_attached
:cv
has_one_attached
:cv
validates
:cv
,
content_type:
{
in:
ACCEPT_CONTENT_TYPE
,
message:
'must be a valid cv format'
},
size:
{
less_than:
5
.
megabytes
,
message:
'should be less than 5MB'
}
def
update_without_password
(
params
,
*
options
)
if
params
[
:password
].
blank?
params
.
delete
(
:password
)
params
.
delete
(
:password_confirmation
)
if
params
[
:password_confirmation
].
blank?
end
result
=
update
(
params
,
*
options
)
clean_up_passwords
result
end
protected
protected
def
password_required?
def
password_required?
...
...
app/views/users/passwords/new.html.slim
0 → 100644
View file @
afd86273
-
provide
(
:title
,
'Forgot password'
)
.container
.row.justify-content-center
.col-6
h2
.text-center.my-5
|
Forgot password
=
form_for
(
resource
,
as:
resource_name
,
url:
password_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
=
render
'users/shared/error_messages'
,
resource:
resource
.field.row.form-group.mb-4
.col-2
=
f
.
label
:email
,
class:
'form-label'
.col-10
=
f
.
email_field
:email
,
autofocus:
true
,
autocomplete:
'email'
,
class:
'form-control mb-2'
span
.form-msg
-
if
devise_mapping
.
confirmable?
&&
controller_name
!=
'confirmations'
p
=
link_to
"Didn't receive confirmation instructions?"
,
new_confirmation_path
(
resource_name
),
class:
'text-decoration-none'
.actions.row.justify-content-end
.col-10.d-flex.justify-content-center
=
f
.
submit
'Confirm your email'
,
class:
'btn btn-primary w-75 my-4'
,
data:
{
disable_with:
false
}
javascript:
Validator
({
form
:
'#new_user'
,
errorSelector
:
'.form-msg'
,
rules
:
[
Validator
.
isRequired
(
'#user_email'
),
Validator
.
isEmail
(
'#user_email'
)
]
})
app/views/users/registrations/edit.html.slim
View file @
afd86273
...
@@ -37,6 +37,12 @@
...
@@ -37,6 +37,12 @@
.col-9
.col-9
=
f
.
text_field
:phone
,
autofocus:
true
,
autocomplete:
'phone'
,
class:
'form-control mb-2'
=
f
.
text_field
:phone
,
autofocus:
true
,
autocomplete:
'phone'
,
class:
'form-control mb-2'
span
.form-msg
span
.form-msg
.field.row.mb-2.form-group
.col-3
=
f
.
label
:cv
,
class:
'form-label'
.col-9
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
,
class:
'form-control'
,
direct_upload:
true
.row.my-4.justify-content-end
.row.my-4.justify-content-end
.col-9
.col-9
hr
hr
...
...
app/views/users/registrations/infomation.html.slim
View file @
afd86273
...
@@ -43,20 +43,27 @@
...
@@ -43,20 +43,27 @@
.col-9
.col-9
=
f
.
password_field
:password_confirmation
,
autocomplete:
'new-password'
,
class:
'form-control mb-2'
=
f
.
password_field
:password_confirmation
,
autocomplete:
'new-password'
,
class:
'form-control mb-2'
span
.form-msg
span
.form-msg
.field.row.mb-2.form-group
.col-3
=
f
.
label
:cv
,
class:
'form-label'
.col-9
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
,
class:
'form-control'
,
direct_upload:
true
.actions.row.justify-content-end
.actions.row.justify-content-end
.col-9
.col-9
=
f
.
submit
'Register'
,
class:
'btn btn-primary w-50 my-4'
,
data:
{
disable_with:
false
}
=
f
.
submit
'Register'
,
class:
'btn btn-primary w-50 my-4'
,
data:
{
disable_with:
false
}
/
javascript:
javascript:
Validator
({
Validator
({
form
:
'
#
edit
_user
',
form
:
'#
new
_user'
,
errorSelector
:
'.form-msg'
,
errorSelector
:
'.form-msg'
,
rules
:
[
rules
:
[
Validator
.isRequired
('
#user_email
'),
Validator
.isEmail
('
#user_email
'),
Validator
.
isRequired
(
'#user_name'
),
Validator
.
isRequired
(
'#user_name'
),
Validator
.
isRequired
(
'#user_address'
),
Validator
.
isRequired
(
'#user_address'
),
Validator
.
isRequired
(
'#user_phone'
),
Validator
.
isRequired
(
'#user_phone'
),
Validator
.isRequired
('
#user_current_password
')
Validator
.
isRequired
(
'#user_password'
),
Validator
.
isRequired
(
'#user_password_confirmation'
),
Validator
.
isConfirmed
(
'#user_password_confirmation'
,
function
()
{
return
document
.
querySelector
(
'#new_user #user_password'
).
value
;
},
'password confirmation does not match'
)
]
]
})
})
\ No newline at end of file
app/views/users/sessions/new.html.slim
View file @
afd86273
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
=
f
.
submit
'Log in'
,
class:
'btn btn-primary w-25'
,
data:
{
disable_with:
false
}
=
f
.
submit
'Log in'
,
class:
'btn btn-primary w-25'
,
data:
{
disable_with:
false
}
=
link_to
'Sign up'
,
new_registration_path
(
resource_name
),
class:
'text-decoration-none w-25 btn btn-secondary'
=
link_to
'Sign up'
,
new_registration_path
(
resource_name
),
class:
'text-decoration-none w-25 btn btn-secondary'
javascript:
javascript:
Validator
({
Validator
({
form
:
'#new_user'
,
form
:
'#new_user'
,
...
...
app/views/users/show.html.slim
View file @
afd86273
...
@@ -88,7 +88,15 @@
...
@@ -88,7 +88,15 @@
h6
.mb-0
Address
h6
.mb-0
Address
.col-sm-9.text-secondary
.col-sm-9.text-secondary
=
@user
.
address
=
@user
.
address
hr
/
.row
.col-sm-3
h6
.mb-0
CV
.col-sm-9.text-secondary
-
if
@user
.
cv
.
attached?
=
link_to
@user
.
cv
.
filename
,
rails_blob_path
(
@user
.
cv
,
disposition:
"attachment"
)
-
else
=
'cv file not uploaded yet'
hr
/
hr
/
.row
.row
.col-sm-12
.col-sm-12
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment