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
2
Merge Requests
2
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
Thanh Hung Pham
veNJOB
Commits
fa9f23e6
Commit
fa9f23e6
authored
Jul 21, 2017
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix comment validate
parent
98594865
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
25 deletions
+61
-25
app/controllers/jobs_controller.rb
+27
-11
app/models/apply_form.rb
+19
-0
app/views/jobs/apply.html.erb
+6
-6
app/views/jobs/confirm.html.erb
+7
-8
config/locales/en.yml
+2
-0
No files found.
app/controllers/jobs_controller.rb
View file @
fa9f23e6
...
...
@@ -10,25 +10,41 @@ class JobsController < ApplicationController
end
def
apply
@job_id
=
params
[
:job_id
]
@fullname
=
params
[
:fullname
].
present?
?
params
[:
fullname
]
:
current_user
.
fullname
@email
=
params
[
:email
].
present?
?
params
[:
email
]
:
current_user
.
email
@apply_form
=
ApplyForm
.
new
(
apply_params
)
@apply_form
.
fullname
||=
current_user
.
fullname
@apply_form
.
email
||=
current_user
.
email
@apply_form
.
job_id
||=
params
[
:job_id
]
end
def
apply_params
params
.
permit
(
:fullname
,
:email
)
end
def
confirm
@fullname
=
params
[
:fullname
]
@email
=
params
[
:email
]
@job_id
=
params
[
:job_id
]
@apply_form
=
ApplyForm
.
new
(
confirm_params
)
return
if
@apply_form
.
valid?
flash
[
:error
]
=
@apply_form
.
errors
.
full_messages
.
to_sentence
render
jobs_apply_path
end
def
confirm_params
params
.
require
(
:apply_form
).
permit
(
:fullname
,
:email
,
:job_id
)
end
def
done
@email
=
params
[
:email
]
@fullname
=
params
[
:fullname
]
@apply_form
=
ApplyForm
.
new
(
confirm_params
)
@cv_link
=
'link to download'
@job
=
Job
.
find
(
params
[
:job_id
])
@job
=
Job
.
find
(
@apply_form
.
job_id
)
@apply_job
=
Apply
.
new
(
user:
current_user
,
job:
@job
,
applied_at:
Time
.
zone
.
now
)
if
@apply_job
.
save
ApplyMailer
.
apply_mail
(
@apply_form
.
email
,
@apply_form
.
fullname
,
@cv_link
,
@job
).
deliver_now
flash
[
:success
]
=
'Apply success!'
else
flash
[
:error
]
=
'Apply error!'
render
jobs_apply_path
end
@apply_job
=
Apply
.
new
(
user:
current_user
,
job:
@job
,
applied_at:
Time
.
zone
.
now
).
save
ApplyMailer
.
apply_mail
(
@email
,
@fullname
,
@cv_link
,
@job
).
deliver
end
def
show
...
...
app/models/apply_form.rb
0 → 100644
View file @
fa9f23e6
class
ApplyForm
include
ActiveModel
::
Model
EMAIL_REG
=
/\A([\w\'"\/\.\(\)\[\]\$\?\*\-%&=,#!:\+;\~_]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})\z/
.
freeze
attr_accessor
:fullname
,
:email
,
:job_id
def
initialize
(
params
)
@fullname
=
params
[
:fullname
]
@email
=
params
[
:email
]
@job_id
=
params
[
:job_id
]
end
validates
:fullname
,
presence:
true
,
length:
{
maximum:
200
}
validates
:email
,
presence:
true
,
format:
{
with:
EMAIL_REG
,
allow_blank:
true
,
allow_nil:
true
,
length:
{
maximum:
250
}
}
end
app/views/jobs/apply.html.erb
View file @
fa9f23e6
...
...
@@ -9,15 +9,15 @@
</div>
<h2>
Apply Form
</h2>
<%=
form_
tag
jobs_confirm_path
do
%>
<%=
form_
for
(
:apply_form
,
url:
jobs_confirm_path
)
do
|
f
|
%>
<div
class=
"form-group"
>
<label>
Full
n
ame
</label><br
/>
<%=
text_field_tag
'fullname'
,
@fullname
,
class:
'form-control'
,
required:
true
%>
<%=
hidden_field_tag
'job_id'
,
@
job_id
%>
<label>
Full
N
ame
</label><br
/>
<%=
f
.
text_field
:fullname
,
class:
'form-control'
%>
<%=
f
.
hidden_field
:
job_id
%>
</div>
<div
class=
"form-group"
>
<label>
Email
</label><br
/>
<%=
text_field_tag
'email'
,
@email
,
class:
'form-control'
,
required:
true
,
pattern:
'[^@]+@[^@]+\.[a-zA-Z]{2,6}'
%>
<%=
f
.
text_field
:email
,
class:
'form-control'
%>
</div>
<div
class=
"form-group"
>
<label>
Cv name
</label><br
/>
...
...
@@ -25,7 +25,7 @@
</div>
<div
class=
"form-group"
>
<%=
submit_tag
'Confirm'
,
class:
'btn btn-primary'
%>
<%=
f
.
submit
'Confirm'
,
class:
'btn btn-primary'
%>
</div>
<%-
end
-%>
</div>
app/views/jobs/confirm.html.erb
View file @
fa9f23e6
...
...
@@ -9,24 +9,23 @@
</div>
<h2>
Apply Confirmation
</h2>
<%=
form_
tag
jobs_done_path
do
%>
<%=
form_
for
(
:apply_form
,
url:
jobs_done_path
)
do
|
f
|
%>
<div
class=
"form-group"
>
<label>
Full
n
ame
</label><br
/>
<%=
text_field_tag
'fullname'
,
@
fullname
,
class:
'form-control'
,
readonly:
true
%>
<%=
hidden_field_tag
'job_id'
,
@
job_id
%>
<label>
Full
N
ame
</label><br
/>
<%=
f
.
text_field
:
fullname
,
class:
'form-control'
,
readonly:
true
%>
<%=
f
.
hidden_field
:
job_id
%>
</div>
<div
class=
"form-group"
>
<label>
Email
</label><br
/>
<%=
text_field_tag
'email'
,
@
email
,
class:
'form-control'
,
readonly:
true
%>
<%=
f
.
text_field
:
email
,
class:
'form-control'
,
readonly:
true
%>
</div>
<div
class=
"form-group"
>
<label>
Cv name
</label><br
/>
<%=
link_to
current_user
.
cv_name
,
registrations_download_file_path
%>
</div>
<div
class=
"form-group"
>
<
a
class=
"btn btn-primary"
href=
"
<%=
jobs_apply_path
(
fullname:
@fullname
,
email:
@email
)
%>
"
>
Edit
</a
>
<%=
submit_tag
'Done'
,
class:
'btn btn-primary'
%>
<
%=
link_to
'Edit'
,
jobs_apply_path
,
class:
'btn btn-primary'
%
>
<%=
f
.
submit
'Done'
,
class:
'btn btn-primary'
%>
</div>
<%-
end
-%>
</div>
config/locales/en.yml
View file @
fa9f23e6
...
...
@@ -35,3 +35,5 @@ en:
user
:
fullname
:
"
Full
Name"
current_password
:
'
Old
password'
apply_form
:
fullname
:
"
Full
Name"
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