Projet

Général

Profil

Development #18624

views: ajouter un hook modify_context_data dans ProfileView.get_context_data() en fin de méthode

Ajouté par Benjamin Dauvergne il y a plus de 6 ans. Mis à jour il y a plus de 6 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
-
Version cible:
-
Début:
12 septembre 2017
Echéance:
% réalisé:

100%

Temps estimé:
Patch proposed:
Non
Planning:

Description

Le hook reçoit en premier argument l'instance de la vue et en deuxième argument l'instance du contexte qu'il pourra modifier.

C'est utilisé sur le CUT dans authentic2-cut de cette manière dans authentic2_cut/apps.py sur le AppConfig:

    def a2_hook_modify_context_data(self, view, context):
        from .custom_settings import CORE_ATTRIBUTES, CROWN_ATTRIBUTES

        if view.__class__.__name__ == 'ProfileView':
            context['cut_core_filled'] = all(getattr(view.request.user.attributes, a, None) for a in
                                             CORE_ATTRIBUTES)
            context['cut_crown_filled'] = any(getattr(view.request.user.attributes, a, None) for a
                                              in CROWN_ATTRIBUTES)

Révisions associées

Révision a7dba134 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 6 ans

views: add hook modify_context_data on ProfileView (fixes #18624)

Historique

#1

Mis à jour par Benjamin Dauvergne il y a plus de 6 ans

  • Statut changé de Nouveau à Résolu (à déployer)
  • % réalisé changé de 0 à 100
#2

Mis à jour par Benjamin Dauvergne il y a plus de 6 ans

  • Statut changé de Résolu (à déployer) à Fermé

Formats disponibles : Atom PDF