Page templates (views/website_pages.xml): - Footer social icons pointed at facebook.com/youtube.com/instagram.com homepages; now TNCSC's own profiles. - "View Event" pointed at a static product mock-up; now /event. - Home "Book Now", Events "Register Event" and the picnic page's "Add To Cart" (which went to /contact) now open the real Summer Picnic registration, falling back to /event if that event is missing. - Home All/Event tabs were href="#"; now /event. - About "Learn More" went to the contact form; relabelled "Contact Us". - Benefits "Become A Member" now goes to /membership/registration. Stock Odoo chrome on built-in pages (login, event/school registration): - Footer replaced with a TNCSC footer (real links, company email, only configured social profiles) instead of demo content with info@yourcompany.example.com, a 555 number and dead "#" links. Priority 90 so it also wins over the website-specific footer copy on the server. - Header "Contact Us" now goes to /contact; the demo phone number is replaced by the company email. community_portal: /my and /my/home (the "Member Login" target) returned a 500 for anonymous visitors because of this Odoo build's auth='user' redirect bug; they now redirect to the login page. website_pages.xml is noupdate, so upgrades never applied template fixes. The 19.0.1.2.0 pre-migrate reloads it once in init mode (this overwrites website-editor edits to those pages; none exist on the server). Verified locally: upgrade of tncsc_site succeeds, every internal link on 16 pages resolves (200/30x), and a fresh install passes 34/34 tests for community_membership, community_portal and tncsc_deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
3.0 KiB
Python
70 lines
3.0 KiB
Python
from odoo import http
|
|
from odoo.addons.portal.controllers.portal import CustomerPortal
|
|
from odoo.http import request
|
|
|
|
SOFT_DETECTED_MODULES = (
|
|
'community_membership',
|
|
'event_qr_ticketing',
|
|
'community_school',
|
|
'community_benefits',
|
|
'community_classifieds',
|
|
)
|
|
|
|
|
|
class CommunityPortalDashboard(CustomerPortal):
|
|
|
|
def _get_installed_community_modules(self):
|
|
"""Soft-detect which Community OS product modules are installed."""
|
|
installed = request.env['ir.module.module'].sudo().search([
|
|
('name', 'in', list(SOFT_DETECTED_MODULES)),
|
|
('state', '=', 'installed'),
|
|
])
|
|
return set(installed.mapped('name'))
|
|
|
|
def _prepare_home_portal_values(self, counters):
|
|
values = super()._prepare_home_portal_values(counters)
|
|
partner = request.env.user.partner_id
|
|
installed = self._get_installed_community_modules()
|
|
|
|
if 'event_registration_count' in counters and 'event_qr_ticketing' in installed:
|
|
values['event_registration_count'] = request.env['event.registration'].sudo().search_count([
|
|
('partner_id', '=', partner.id),
|
|
])
|
|
|
|
if 'school_enrollment_count' in counters and 'community_school' in installed:
|
|
values['school_enrollment_count'] = request.env['community.school.student'].sudo().search_count([
|
|
('parent_partner_id', '=', partner.id),
|
|
])
|
|
|
|
if 'benefits_count' in counters and 'community_benefits' in installed:
|
|
Benefit = request.env['community.benefit'].sudo()
|
|
entitled = Benefit.search(Benefit._entitled_domain_for_partner(partner))
|
|
values['benefits_count'] = len(entitled.filtered(lambda b: b.is_entitled(partner)))
|
|
|
|
if 'classifieds_count' in counters and 'community_classifieds' in installed:
|
|
values['classifieds_count'] = request.env['community.classified'].sudo().search_count([
|
|
('poster_partner_id', '=', partner.id),
|
|
])
|
|
|
|
return values
|
|
|
|
@http.route(['/my', '/my/home'], type='http', auth='public', website=True)
|
|
def home(self, **kw):
|
|
# Core declares these auth='user', which on this Odoo build returns a
|
|
# 500 for anonymous visitors instead of redirecting to login (see
|
|
# community_classifieds' _redirect_to_login_if_public). "Member Login"
|
|
# links point here, so check auth ourselves.
|
|
if request.env.user._is_public():
|
|
return request.redirect('/web/login?redirect=/my')
|
|
return super().home(**kw)
|
|
|
|
@http.route(['/my/school'], type='http', auth='public', website=True)
|
|
def portal_my_school(self, **kwargs):
|
|
if request.env.user._is_public():
|
|
return request.redirect('/web/login?redirect=/my/school')
|
|
partner = request.env.user.partner_id
|
|
students = request.env['community.school.student'].sudo().search([
|
|
('parent_partner_id', '=', partner.id),
|
|
])
|
|
return request.render('community_portal.portal_my_school', {'students': students})
|