diff --git a/ssi_partner_experience_portal/controllers/__init__.py b/ssi_partner_experience_portal/controllers/__init__.py index 6f7cc31..265f233 100644 --- a/ssi_partner_experience_portal/controllers/__init__.py +++ b/ssi_partner_experience_portal/controllers/__init__.py @@ -2,6 +2,4 @@ # Copyright 2024 PT. Simetri Sinergi Indonesia # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import ( - portal -) +from . import portal diff --git a/ssi_partner_experience_portal/controllers/portal.py b/ssi_partner_experience_portal/controllers/portal.py index e346ab1..b5d0e48 100644 --- a/ssi_partner_experience_portal/controllers/portal.py +++ b/ssi_partner_experience_portal/controllers/portal.py @@ -2,18 +2,10 @@ # Copyright 2024 PT. Simetri Sinergi Indonesia # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -import base64 -import functools -import json import logging -import math -import re - -from werkzeug import urls -from odoo import fields as odoo_fields, http, tools, _, SUPERUSER_ID -from odoo.exceptions import ValidationError, AccessError, MissingError, UserError, AccessDenied -from odoo.http import content_disposition, Controller, request, route -from odoo.tools import consteq + +from odoo.http import request, route + from odoo.addons.portal.controllers import portal from odoo.addons.portal.controllers.portal import CustomerPortal @@ -21,218 +13,229 @@ class CustomerPortalExtended(CustomerPortal): - - @route( - ['/my/academics'], - type='http', - auth='user', - website=True, - methods=['GET'] - ) + @route(["/my/academics"], type="http", auth="user", website=True, methods=["GET"]) def academics(self): values = self._prepare_portal_layout_values() - values['get_error'] = portal.get_error - values['academic_ids'] = request.env['portal_partner_academic'].search([ - ('partner_id', '=', request.env.user.partner_id.id) - ]) + values["get_error"] = portal.get_error + values["academic_ids"] = request.env["portal_partner_academic"].search( + [("partner_id", "=", request.env.user.partner_id.id)] + ) - return request.render('ssi_partner_experience_portal.portal_my_academics', values, headers={ - 'X-Frame-Options': 'DENY' - }) + return request.render( + "ssi_partner_experience_portal.portal_my_academics", + values, + headers={"X-Frame-Options": "DENY"}, + ) @route( - ['/my/academic', '/my/academic/'], - type='http', - auth='user', + ["/my/academic", "/my/academic/"], + type="http", + auth="user", website=True, - methods=['GET', 'POST'] + methods=["GET", "POST"], ) def academic(self, **post): - id = post.get('id') - partner_obj = request.env['res.partner'].sudo() - academic_obj = request.env['portal_partner_academic'] - education_level_obj = request.env['partner.formal_education_level'] - field_of_study_obj = request.env['partner.field_of_study'] + id = post.get("id") + partner_obj = request.env["res.partner"].sudo() + academic_obj = request.env["portal_partner_academic"] + education_level_obj = request.env["partner.formal_education_level"] + field_of_study_obj = request.env["partner.field_of_study"] values = self._prepare_portal_layout_values() error_messages = [] - values.update({ - 'error_message': '', - 'partner_address_ids': partner_obj.search([('is_company', '=', True)]), - 'education_level_ids': education_level_obj.search([]), - 'field_of_study_ids': field_of_study_obj.search([]), - 'current_academic_id': academic_obj, - }) + values.update( + { + "error_message": "", + "partner_address_ids": partner_obj.search([("is_company", "=", True)]), + "education_level_ids": education_level_obj.search([]), + "field_of_study_ids": field_of_study_obj.search([]), + "current_academic_id": academic_obj, + } + ) current_academic_id = academic_obj if id: id = int(id) - current_academic_id = academic_obj.search([ - ('id', '=', id) - ]) - values.update({ - 'current_academic_id': current_academic_id, - }) - - if request.httprequest.method == 'POST': + current_academic_id = academic_obj.search([("id", "=", id)]) + values.update( + { + "current_academic_id": current_academic_id, + } + ) + + if request.httprequest.method == "POST": academic_vals = { - 'partner_id': request.env.user.partner_id.id, - 'location': post.get('location'), - 'date_start': post.get('date_start') or False, - 'expire': post.get('expire'), - 'date_end': post.get('date_end') or False, - 'diploma': post.get('diploma'), - 'gpa': post.get('gpa'), - 'activities': post.get('activities'), - 'note': post.get('note'), + "partner_id": request.env.user.partner_id.id, + "location": post.get("location"), + "date_start": post.get("date_start") or False, + "expire": post.get("expire"), + "date_end": post.get("date_end") or False, + "diploma": post.get("diploma"), + "gpa": post.get("gpa"), + "activities": post.get("activities"), + "note": post.get("note"), } - if post.get('partner_address'): - partner_address_id = partner_obj.sudo().search([ - ('id', '=', int(post.get('partner_address', '0'))) - ]) + if post.get("partner_address"): + partner_address_id = partner_obj.sudo().search( + [("id", "=", int(post.get("partner_address", "0")))] + ) if not partner_address_id: - error_messages.append('Institution not found.') - academic_vals.update({ - 'partner_address_id': partner_address_id.id, - }) - if post.get('education_level'): - education_level_id = education_level_obj.sudo().search([ - ('id', '=', int(post.get('education_level', '0'))) - ]) + error_messages.append("Institution not found.") + academic_vals.update( + { + "partner_address_id": partner_address_id.id, + } + ) + if post.get("education_level"): + education_level_id = education_level_obj.sudo().search( + [("id", "=", int(post.get("education_level", "0")))] + ) if not education_level_id: - error_messages.append('Education level not found.') - academic_vals.update({ - 'education_level_id': education_level_id.id, - }) - if post.get('field_of_study'): - field_of_study_id = field_of_study_obj.sudo().search([ - ('id', '=', int(post.get('field_of_study', '0'))) - ]) + error_messages.append("Education level not found.") + academic_vals.update( + { + "education_level_id": education_level_id.id, + } + ) + if post.get("field_of_study"): + field_of_study_id = field_of_study_obj.sudo().search( + [("id", "=", int(post.get("field_of_study", "0")))] + ) if not field_of_study_id: - error_messages.append('Field of Study not found.') - academic_vals.update({ - 'field_of_study_id': field_of_study_id.id, - }) + error_messages.append("Field of Study not found.") + academic_vals.update( + { + "field_of_study_id": field_of_study_id.id, + } + ) if error_messages: - values['error_message'] = '\n'.join(error_messages) - return request.render('ssi_partner_experience_portal.portal_my_academic', values, headers={ - 'X-Frame-Options': 'DENY' - }) + values["error_message"] = "\n".join(error_messages) + return request.render( + "ssi_partner_experience_portal.portal_my_academic", + values, + headers={"X-Frame-Options": "DENY"}, + ) if not current_academic_id: academic_obj.create(academic_vals) else: current_academic_id.write(academic_vals) - return request.redirect('/my/academics') + return request.redirect("/my/academics") - return request.render('ssi_partner_experience_portal.portal_my_academic', values, headers={ - 'X-Frame-Options': 'DENY' - }) + return request.render( + "ssi_partner_experience_portal.portal_my_academic", + values, + headers={"X-Frame-Options": "DENY"}, + ) @route( - ['/my/academic/remove/'], - type='http', - auth='user', + ["/my/academic/remove/"], + type="http", + auth="user", website=True, - methods=['GET', 'POST'] + methods=["GET", "POST"], ) def remove_academic(self, **post): - id = post.get('id') - academic_id = request.env['portal_partner_academic'].search([ - ('id', '=', int(id)) - ]) + id = post.get("id") + academic_id = request.env["portal_partner_academic"].search( + [("id", "=", int(id))] + ) academic_id.unlink() - return request.redirect('/my/academics') + return request.redirect("/my/academics") - @route( - ['/my/experiences'], - type='http', - auth='user', - website=True, - methods=['GET'] - ) + @route(["/my/experiences"], type="http", auth="user", website=True, methods=["GET"]) def experiences(self): values = self._prepare_portal_layout_values() - values['get_error'] = portal.get_error - values['experience_ids'] = request.env['portal_partner_experience'].search([ - ('partner_id', '=', request.env.user.partner_id.id) - ]) + values["get_error"] = portal.get_error + values["experience_ids"] = request.env["portal_partner_experience"].search( + [("partner_id", "=", request.env.user.partner_id.id)] + ) - return request.render('ssi_partner_experience_portal.portal_my_experiences', values, headers={ - 'X-Frame-Options': 'DENY' - }) + return request.render( + "ssi_partner_experience_portal.portal_my_experiences", + values, + headers={"X-Frame-Options": "DENY"}, + ) @route( - ['/my/experience', '/my/experience/'], - type='http', - auth='user', + ["/my/experience", "/my/experience/"], + type="http", + auth="user", website=True, - methods=['GET', 'POST'] + methods=["GET", "POST"], ) def experience(self, **post): - id = post.get('id') - partner_obj = request.env['res.partner'].sudo() - experience_obj = request.env['portal_partner_experience'] + id = post.get("id") + partner_obj = request.env["res.partner"].sudo() + experience_obj = request.env["portal_partner_experience"] values = self._prepare_portal_layout_values() error_messages = [] - values.update({ - 'error_message': '', - 'partner_address_ids': partner_obj.search([('is_company', '=', True)]), - 'current_experience_id': experience_obj, - }) + values.update( + { + "error_message": "", + "partner_address_ids": partner_obj.search([("is_company", "=", True)]), + "current_experience_id": experience_obj, + } + ) current_experience_id = experience_obj if id: id = int(id) - current_experience_id = experience_obj.search([ - ('id', '=', id) - ]) - values.update({ - 'current_experience_id': current_experience_id, - }) - - if request.httprequest.method == 'POST': + current_experience_id = experience_obj.search([("id", "=", id)]) + values.update( + { + "current_experience_id": current_experience_id, + } + ) + + if request.httprequest.method == "POST": experience_vals = { - 'partner_id': request.env.user.partner_id.id, - 'job_position': post.get('job_position'), - 'job_level': post.get('job_level'), - 'location': post.get('location'), - 'date_start': post.get('date_start') or False, - 'expire': post.get('expire'), - 'date_end': post.get('date_end') or False, - 'note': post.get('note'), + "partner_id": request.env.user.partner_id.id, + "job_position": post.get("job_position"), + "job_level": post.get("job_level"), + "location": post.get("location"), + "date_start": post.get("date_start") or False, + "expire": post.get("expire"), + "date_end": post.get("date_end") or False, + "note": post.get("note"), } - if post.get('partner_address'): - partner_address_id = partner_obj.sudo().search([ - ('id', '=', int(post.get('partner_address', '0'))) - ]) + if post.get("partner_address"): + partner_address_id = partner_obj.sudo().search( + [("id", "=", int(post.get("partner_address", "0")))] + ) if not partner_address_id: - error_messages.append('Institution not found.') - experience_vals.update({ - 'partner_address_id': partner_address_id.id, - }) + error_messages.append("Institution not found.") + experience_vals.update( + { + "partner_address_id": partner_address_id.id, + } + ) if error_messages: - values['error_message'] = '\n'.join(error_messages) - return request.render('ssi_partner_experience_portal.portal_my_experience', values, headers={ - 'X-Frame-Options': 'DENY' - }) + values["error_message"] = "\n".join(error_messages) + return request.render( + "ssi_partner_experience_portal.portal_my_experience", + values, + headers={"X-Frame-Options": "DENY"}, + ) if not current_experience_id: experience_obj.create(experience_vals) else: current_experience_id.write(experience_vals) - return request.redirect('/my/experiences') + return request.redirect("/my/experiences") - return request.render('ssi_partner_experience_portal.portal_my_experience', values, headers={ - 'X-Frame-Options': 'DENY' - }) + return request.render( + "ssi_partner_experience_portal.portal_my_experience", + values, + headers={"X-Frame-Options": "DENY"}, + ) @route( - ['/my/experience/remove/'], - type='http', - auth='user', + ["/my/experience/remove/"], + type="http", + auth="user", website=True, - methods=['GET', 'POST'] + methods=["GET", "POST"], ) def remove_experience(self, **post): - id = post.get('id') - experience_id = request.env['portal_partner_experience'].search([ - ('id', '=', int(id)) - ]) + id = post.get("id") + experience_id = request.env["portal_partner_experience"].search( + [("id", "=", int(id))] + ) experience_id.unlink() - return request.redirect('/my/experiences') + return request.redirect("/my/experiences") diff --git a/ssi_partner_experience_portal/models/portal_partner_academic.py b/ssi_partner_experience_portal/models/portal_partner_academic.py index d2de9f0..b10eb38 100644 --- a/ssi_partner_experience_portal/models/portal_partner_academic.py +++ b/ssi_partner_experience_portal/models/portal_partner_academic.py @@ -2,15 +2,12 @@ # Copyright 2024 PT. Simetri Sinergi Indonesia # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError +from odoo import models class PortalPartnerAcademic(models.Model): _name = "portal_partner_academic" - _inherit = [ - 'partner.academic' - ] + _inherit = ["partner.academic"] _description = "Portal Partner Academic" _table = "partner_academic" _order = "date_start" diff --git a/ssi_partner_experience_portal/models/portal_partner_experience.py b/ssi_partner_experience_portal/models/portal_partner_experience.py index 751fa6d..f1fa527 100644 --- a/ssi_partner_experience_portal/models/portal_partner_experience.py +++ b/ssi_partner_experience_portal/models/portal_partner_experience.py @@ -2,15 +2,12 @@ # Copyright 2024 PT. Simetri Sinergi Indonesia # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError +from odoo import models class PortalPartnerExperience(models.Model): _name = "portal_partner_experience" - _inherit = [ - 'partner.experience' - ] + _inherit = ["partner.experience"] _description = "Portal Partner Experience" _table = "partner_experience" _order = "date_start" diff --git a/ssi_partner_experience_portal/security/ir.model.access.csv b/ssi_partner_experience_portal/security/ir.model.access.csv index 969adef..9d3e4f1 100644 --- a/ssi_partner_experience_portal/security/ir.model.access.csv +++ b/ssi_partner_experience_portal/security/ir.model.access.csv @@ -2,4 +2,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_portal_partner_academic_user,portal_partner_academic - user,model_portal_partner_academic,base.group_user,1,1,1,1 access_portal_partner_experience_user,portal_partner_experience - user,model_portal_partner_experience,base.group_user,1,1,1,1 access_portal_partner_academic_portal,portal_partner_academic - portal,model_portal_partner_academic,base.group_portal,1,1,1,1 -access_portal_partner_experience_portal,portal_partner_experience - portal,model_portal_partner_experience,base.group_portal,1,1,1,1 \ No newline at end of file +access_portal_partner_experience_portal,portal_partner_experience - portal,model_portal_partner_experience,base.group_portal,1,1,1,1 diff --git a/ssi_partner_experience_portal/static/src/scss/portal.scss b/ssi_partner_experience_portal/static/src/scss/portal.scss index 9a55665..345b0e9 100644 --- a/ssi_partner_experience_portal/static/src/scss/portal.scss +++ b/ssi_partner_experience_portal/static/src/scss/portal.scss @@ -7,7 +7,8 @@ // for the absolutely positioned meter on new password position: relative; } - label, button { + label, + button { @extend .text-nowrap; } } @@ -26,7 +27,8 @@ // for the absolutely positioned meter on new password position: relative; } - label, button { + label, + button { @extend .text-nowrap; } } @@ -41,7 +43,8 @@ // for the absolutely positioned meter on new password position: relative; } - label, button { + label, + button { @extend .text-nowrap; } } @@ -60,7 +63,8 @@ // for the absolutely positioned meter on new password position: relative; } - label, button { + label, + button { @extend .text-nowrap; } } diff --git a/ssi_partner_experience_portal/views/assets.xml b/ssi_partner_experience_portal/views/assets.xml index f15efd4..de6bd55 100644 --- a/ssi_partner_experience_portal/views/assets.xml +++ b/ssi_partner_experience_portal/views/assets.xml @@ -1,8 +1,17 @@ - + - @@ -34,7 +38,11 @@ @@ -45,8 +53,8 @@ Field of Study Date Start Date End - - + + @@ -62,10 +70,18 @@ - Edit + Edit - Delete + Delete @@ -80,32 +96,65 @@

Academic Experience

-
- - + + +
- +
- +
- +
- +
- +
@@ -136,25 +201,48 @@
- +
- +
- +
- @@ -191,8 +283,8 @@ Employer Date Start Date End - - + + @@ -207,10 +299,18 @@ - Edit + Edit - Delete + Delete @@ -225,42 +325,83 @@

Professional Experiences

- - - + + +
- +
- +
- +
- +
- +
- +
- +
-