-
Notifications
You must be signed in to change notification settings - Fork 1
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
[ADD] hr_recruitment_job_share: Share a job that wasnt published in website #62
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
======================== | ||
Hr Recruitment Job Share | ||
======================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:f65466fa3db1bf38827a26dc5413e069b9dfd9a720389cabcabe608918cae583 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-KMEE%2Fkmee--odoo--addons-lightgray.png?logo=github | ||
:target: https://github.com/KMEE/kmee-odoo-addons/tree/16.0/hr_recruitment_job_share | ||
:alt: KMEE/kmee-odoo-addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
It allows the user to share details of a job that has not been published | ||
on the site yet | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Access the work record, click "Share" and copy the link | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/KMEE/kmee-odoo-addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/KMEE/kmee-odoo-addons/issues/new?body=module:%20hr_recruitment_job_share%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* KMEE | ||
|
||
Contributors | ||
------------ | ||
|
||
- ``KMEE <https://www.kmee.com.br>``\ \_: | ||
|
||
- Bruno Corredato Botti | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is part of the `KMEE/kmee-odoo-addons <https://github.com/KMEE/kmee-odoo-addons/tree/16.0/hr_recruitment_job_share>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
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,3 @@ | ||
from . import controllers | ||
from . import models | ||
from . import wizards |
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,21 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Hr Recruitment Job Share", | ||
"summary": """ | ||
Share job in odoo portal""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "KMEE,Odoo Community Association (OCA)", | ||
"website": "https://github.com/KMEE/kmee-odoo-addons", | ||
"depends": [ | ||
"website_hr_recruitment", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/hr_job.xml", | ||
"views/website_hr_recruitment_templates.xml", | ||
"wizards/job_share.xml", | ||
], | ||
} |
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 @@ | ||
from . import controllers |
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,40 @@ | ||
from werkzeug.exceptions import NotFound | ||
|
||
from odoo import http | ||
from odoo.http import request | ||
|
||
|
||
class JobShareController(http.Controller): | ||
@http.route( | ||
["/jobs/details/<int:hr_job_id>"], type="http", auth="public", website=True | ||
) | ||
def job_followup(self, hr_job_id=None, access_token=None, **kw): | ||
hr_job_sudo = ( | ||
request.env["hr.job"].sudo().search([("id", "=", hr_job_id)], limit=1) | ||
) | ||
|
||
if not hr_job_sudo or hr_job_sudo.access_token != access_token: | ||
raise NotFound() | ||
|
||
values = { | ||
"page_name": "hr_job", | ||
"job": hr_job_sudo, | ||
"access_token": access_token, | ||
} | ||
return request.render("website_hr_recruitment.detail", values) | ||
|
||
@http.route( | ||
["/jobs/apply/<int:hr_job_id>"], type="http", auth="public", website=True | ||
) | ||
def job_apply(self, hr_job_id=None, access_token=None, **kw): | ||
hr_job_sudo = ( | ||
request.env["hr.job"].sudo().search([("id", "=", hr_job_id)], limit=1) | ||
) | ||
|
||
if not hr_job_sudo or ( | ||
hr_job_sudo.access_token != access_token and not hr_job_sudo.is_published | ||
): | ||
raise NotFound() | ||
|
||
values = {"job": hr_job_sudo} | ||
return request.render("website_hr_recruitment.apply", values) |
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 @@ | ||
from . import hr_job |
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,48 @@ | ||
import secrets | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class Job(models.Model): | ||
_inherit = "hr.job" | ||
|
||
access_token = fields.Char( | ||
"Token de Acesso", copy=False, default=lambda self: secrets.token_urlsafe(16) | ||
) | ||
is_shared = fields.Boolean("É compartilhado?", default=False) | ||
application_url = fields.Char("URL da Vaga", compute="_compute_application_url") | ||
|
||
def get_share_url(self): | ||
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url") | ||
return f"{base_url}/jobs/details/{self.id}?access_token={self.access_token}" | ||
|
||
@api.depends("access_token") | ||
def _compute_application_url(self): | ||
for job in self: | ||
job.application_url = job.get_share_url() if job.access_token else "" | ||
|
||
def action_share_job(self): | ||
self.ensure_one() | ||
# Gerar um novo token ao compartilhar o trabalho | ||
self.access_token = secrets.token_urlsafe(16) # Garante que cada token é único | ||
self.is_shared = True | ||
return { | ||
"type": "ir.actions.act_window", | ||
"res_model": "job.share.wizard", | ||
"view_mode": "form", | ||
"target": "new", | ||
"context": {"default_job_id": self.id}, | ||
} | ||
|
||
@api.model | ||
def create(self, vals): | ||
# Garante que o token de acesso é gerado no momento da criação | ||
if "access_token" not in vals: | ||
vals["access_token"] = secrets.token_urlsafe(16) | ||
return super(Job, self).create(vals) | ||
|
||
def write(self, vals): | ||
# Se o trabalho não estiver sendo compartilhado, não altere o token | ||
if "is_shared" in vals and vals["is_shared"]: | ||
self.access_token = secrets.token_urlsafe(16) | ||
return super(Job, self).write(vals) |
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,3 @@ | ||
* `KMEE <https://www.kmee.com.br>`_: | ||
|
||
* Bruno Corredato Botti |
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 @@ | ||
It allows the user to share details of a job that has not been published on the site yet |
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 @@ | ||
Access the work record, click "Share" and copy the link |
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,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_job_share_wizard,job.share.wizard,model_job_share_wizard,hr_recruitment.group_hr_recruitment_user,1,1,1,1 | ||
access_hr_job_public,access_hr_job_public,model_hr_job,base.group_public,1,0,0,0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
Se duplicar o registro o que acontece?
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.
Ele cria um novo token sempre que o usuário clica em compartilhar, e os anteriores continuam funcional