Skip to content

Commit

Permalink
Merge PR #187 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 18, 2024
2 parents 42346da + 76a074f commit cd65663
Show file tree
Hide file tree
Showing 17 changed files with 746 additions and 0 deletions.
99 changes: 99 additions & 0 deletions website_membership_random_order/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
=======================================
Online Members Directory - Random order
=======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:28dcda5e340375852228f923250604bac3db33a7fd7818874726c6838bf43661
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-OCA%2Fvertical--association-lightgray.png?logo=github
:target: https://github.com/OCA/vertical-association/tree/17.0/website_membership_random_order
:alt: OCA/vertical-association
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/vertical-association-17-0/vertical-association-17-0-website_membership_random_order
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/vertical-association&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This modules extends the online members directory for displaying the
results in a random order, and displays a disclaimer about it at the top
of the list.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

- All the members will be displayed at once, without pager, as this is
the only way to get a whole randomized list. On contrary, paging the
content, on each render, we will get random elements belonging to
that slice. Don't use this module with a long list of members.
- Random mode does not work with free members.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/vertical-association/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/OCA/vertical-association/issues/new?body=module:%20website_membership_random_order%0Aversion:%2017.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
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza
- Stefan Ungureanu
- Carolina Fernandez

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px
:target: https://github.com/pedrobaeza
:alt: pedrobaeza

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pedrobaeza|

This module is part of the `OCA/vertical-association <https://github.com/OCA/vertical-association/tree/17.0/website_membership_random_order>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions website_membership_random_order/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import controllers
from . import models
15 changes: 15 additions & 0 deletions website_membership_random_order/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Tecnativa - Pedro M. Baeza
# Copyright 2023 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Online Members Directory - Random order",
"version": "17.0.1.0.0",
"category": "Association",
"website": "https://github.com/OCA/vertical-association",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["website_membership"],
"maintainers": ["pedrobaeza"],
"data": ["templates/website_membership_templates.xml"],
}
2 changes: 2 additions & 0 deletions website_membership_random_order/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import main
30 changes: 30 additions & 0 deletions website_membership_random_order/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.http import request, route
from odoo.tools import frozendict

from odoo.addons.website_membership.controllers.main import WebsiteMembership


class WebsiteMembership(WebsiteMembership):
# For avoiding the appearance of the pager in the website page
_references_per_page = 9999999

@route()
def members(
self, membership_id=None, country_name=None, country_id=0, page=1, **post
):
"""Inject a context for being queried later on the search of the membership
lines for randomizing the returned order.
"""
request.env.context = frozendict(
request.env.context, random_membership_line_order=True
)
return super().members(
membership_id=membership_id,
country_name=country_name,
country_id=country_id,
page=page,
**post,
)
32 changes: 32 additions & 0 deletions website_membership_random_order/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_membership_random_order
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-14 14:19+0000\n"
"PO-Revision-Date: 2023-10-15 20:36+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: website_membership_random_order
#: model:ir.model,name:website_membership_random_order.model_membership_membership_line
msgid "Membership Line"
msgstr "Línea de membresía"

#. module: website_membership_random_order
#: model_terms:ir.ui.view,arch_db:website_membership_random_order.index
msgid ""
"This order of appearance is random and changes each time you refresh.\n"
" <br/>"
msgstr ""
"Este orden de aparición es aleatorio y cambia cada vez que actualiza.\n"
" <br/>"
32 changes: 32 additions & 0 deletions website_membership_random_order/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_membership_random_order
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-05-12 13:34+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"

#. module: website_membership_random_order
#: model:ir.model,name:website_membership_random_order.model_membership_membership_line
msgid "Membership Line"
msgstr "Riga iscrizione"

#. module: website_membership_random_order
#: model_terms:ir.ui.view,arch_db:website_membership_random_order.index
msgid ""
"This order of appearance is random and changes each time you refresh.\n"
" <br/>"
msgstr ""
"L'ordinei di visualizzazione è causale e cambia e cambia ad ogni "
"aggiornamento.\n"
" <br/>"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_membership_random_order
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: website_membership_random_order
#: model:ir.model,name:website_membership_random_order.model_membership_membership_line
msgid "Membership Line"
msgstr ""

#. module: website_membership_random_order
#: model_terms:ir.ui.view,arch_db:website_membership_random_order.index
msgid ""
"This order of appearance is random and changes each time you refresh.\n"
" <br/>"
msgstr ""
2 changes: 2 additions & 0 deletions website_membership_random_order/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import membership_line
23 changes: 23 additions & 0 deletions website_membership_random_order/models/membership_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import random

from odoo import models


class MembershipLine(models.Model):
_inherit = "membership.membership_line"

def search(self, domain, offset=0, limit=None, order=None):
"""If we detect the injected context, and only when the search is done with
limit (as there are 2 calls to search in the controller), we search for all
the results, randomize them, and return them. We can't do slices, as if not, we
won't be able to show all the records due to the pager and each time returning
random results.
"""
if self.env.context.get("random_membership_line_order") and limit:
record_ids = super().search(domain, limit=None).ids
random.shuffle(record_ids)
return self.browse(record_ids)
return super().search(domain, offset=offset, limit=limit, order=order)
3 changes: 3 additions & 0 deletions website_membership_random_order/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions website_membership_random_order/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- Stefan Ungureanu
- Carolina Fernandez
3 changes: 3 additions & 0 deletions website_membership_random_order/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This modules extends the online members directory for displaying the
results in a random order, and displays a disclaimer about it at the top
of the list.
5 changes: 5 additions & 0 deletions website_membership_random_order/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- All the members will be displayed at once, without pager, as this is
the only way to get a whole randomized list. On contrary, paging the
content, on each render, we will get random elements belonging to that
slice. Don't use this module with a long list of members.
- Random mode does not work with free members.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cd65663

Please sign in to comment.