-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show vacancy to moderators #51
Open
anoam
wants to merge
3
commits into
davydovanton:master
Choose a base branch
from
anoam:show-vacancy-to-moderators
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
/coverage | ||
.idea | ||
.ruby-version | ||
.ruby-gemset | ||
.env.dev | ||
.env.development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Moderation | ||
module Controllers | ||
module Dashboard | ||
class Show | ||
include Moderation::Action | ||
include Dry::Monads::Result::Mixin | ||
include Import[ | ||
operation: 'vacancies.operations.vacancy_for_moderation' | ||
] | ||
|
||
expose :vacancy | ||
|
||
def call(params) | ||
result = operation.call(id: params[:id]) | ||
|
||
case result | ||
when Success | ||
@vacancy = result.value! | ||
when Failure | ||
redirect_to routes.root_path | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# frozen_string_literal: true | ||
|
||
module Moderation | ||
module Helpers | ||
module Vacancy | ||
def approve_button(id) | ||
html.form(action: routes.vacancy_approve_path(id), method: 'POST') do | ||
input(type: 'hidden', name: '_method', value: 'PATCH') | ||
input(type: 'submit', value: 'Принять', class: 'btn btn-success') | ||
end | ||
end | ||
|
||
def disapprove_button(id) | ||
html.form(action: routes.vacancy_disapprove_path(id), method: 'POST') do | ||
input(type: 'hidden', name: '_method', value: 'PATCH') | ||
input(type: 'submit', value: 'Отклонить', class: 'btn btn-warning') | ||
end | ||
end | ||
|
||
def company_text(vacancy) | ||
published_at = RelativeTime.in_words(vacancy.created_at, locale: :ru) | ||
raw "Компания #{company_link(vacancy)} (#{vacancy.location}), опубликована #{published_at}" | ||
end | ||
|
||
def company_link(vacancy) | ||
if vacancy.contact.site | ||
link_to vacancy.contact.company, vacancy.contact.site | ||
else | ||
vacancy.contact.company | ||
end | ||
end | ||
|
||
def remote_badge(vacancy) | ||
return unless vacancy.remote_available | ||
|
||
html.span(class: 'mr-2 badge badge-success') { 'Удаленно' } | ||
end | ||
|
||
def position_type_badge(vacancy) | ||
html.span(class: 'mr-2 badge badge-info') { POSITION_TYPE_VALUES[vacancy.position_type] } | ||
end | ||
|
||
def vacancy_salary_information(vacancy) | ||
currency = CURRENCY_VALUES[vacancy.salary_currency] | ||
unit = UNIT_VALUES[vacancy.salary_unit] | ||
|
||
html.span(class: 'salary') do | ||
text 'от ' | ||
span(class: 'money') { vacancy.salary_min } | ||
text ' до ' | ||
span(class: 'money') { vacancy.salary_max } | ||
text " #{currency} #{unit}" | ||
end | ||
end | ||
|
||
POSITION_TYPE_VALUES = { | ||
'full_time' => 'Полная занятость', | ||
'part_time' => 'Частичная занятость', | ||
'contractor' => 'Работа по контракту', | ||
'intern' => 'Интернатура', | ||
'temp' => 'Временная работа', | ||
'other' => 'Другое' | ||
}.freeze | ||
|
||
CURRENCY_VALUES = { 'rub' => 'рублей', 'usd' => 'долларов', 'eur' => 'евро' }.freeze | ||
|
||
UNIT_VALUES = { | ||
'monthly' => 'в месяц', | ||
'yearly' => 'в год', | ||
'by hour' => 'в час', | ||
'per project' => 'за проект' | ||
}.freeze | ||
|
||
def vacancy_details(vacancy) | ||
raw_body(vacancy.details) | ||
end | ||
|
||
def raw_body(body) | ||
raw(body || '') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
li.list-group-item | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Опять же, вынес в партиал и использовал таким образом как самый простой вариант. |
||
.row | ||
.col-sm-8 | ||
h4 #{vacancy.position} (id: #{vacancy.id}) | ||
.col-sm-4 | ||
= vacancy_salary_information(vacancy) | ||
.row | ||
.col-sm-8 | ||
= company_text(vacancy) | ||
.col-sm-4 | ||
= remote_badge(vacancy) | ||
= position_type_badge(vacancy) | ||
|
||
hr.mb-4.mt-4 | ||
|
||
.row | ||
.col.vacancy_details | ||
= vacancy_details(vacancy) | ||
|
||
.row | ||
.col | ||
= vacancy.tags | ||
|
||
hr.mb-4.mt-4 | ||
|
||
.row | ||
.col | ||
= vacancy.contact.email | ||
|
||
.col | ||
= vacancy.contact.full_name | ||
|
||
hr.mb-4.mt-4 | ||
|
||
.row | ||
.col.mb-4 | ||
= approve_button(vacancy.id) | ||
|
||
.col.mb-4.btn-float-right | ||
= disapprove_button(vacancy.id) | ||
|
||
hr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
h1 Moderation | ||
|
||
hr | ||
|
||
= render partial: 'vacancy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Moderation | ||
module Views | ||
module Dashboard | ||
class Show | ||
include Moderation::View | ||
include Moderation::Helpers::Vacancy | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,11 @@ def disapprove_by_pk(id) | |
end | ||
|
||
def all_for_moderation | ||
aggregate(:contact).where( | ||
published: false, | ||
archived: false, | ||
deleted_at: nil | ||
).map_to(Vacancy).to_a | ||
for_modertion.map_to(Vacancy).to_a | ||
end | ||
|
||
def find_for_moderation(id) | ||
for_modertion.by_pk(id).map_to(Vacancy).one | ||
end | ||
|
||
def find_with_contact(id) | ||
|
@@ -33,4 +33,14 @@ def find_with_contact(id) | |
deleted_at: nil | ||
).by_pk(id).map_to(Vacancy).one | ||
end | ||
|
||
private | ||
|
||
def for_modertion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
aggregate(:contact).where( | ||
published: false, | ||
archived: false, | ||
deleted_at: nil | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vacancies | ||
module Operations | ||
class VacancyForModeration < ::Libs::Operation | ||
include Import[ | ||
vacancy_repo: 'repositories.vacancy' | ||
] | ||
|
||
def call(id:) | ||
vacancy = vacancy_repo.find_for_moderation(id) | ||
vacancy ? Success(vacancy) : Failure(:not_found) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не очень уверен в правильности такого решения.
Просто как самая простая опция.