Exemplo n.º 1
0
    def parse_params(self, request, *args, **kwargs):
        """
        There are two modes of entering this wizard:
        1. At 'gezin' level
        2. At 'persoon' level
        
        Which level is determined by the 'is_mode_family' flag passed
        on entering this wizard. There is also an additional 'updateWholeFamily'
        flag in the user form.
        """
        
        # Read 'whole family' flag
        is_mode_family = kwargs["is_mode_family"]
        
        if (is_mode_family):
            # Extract gezin ID from url
            gezinId = kwargs["gezinId"]
            
            # Check if gezin already retrieved
            if ("gezin" not in self.storedFields 
                or self.storedFields["gezin"].idgezin != gezinId):
                # Not yet retrieved or someone else. Retrieve.
                gezin = Gezin.objects.get(pk=gezinId)
                
                # Add gezin to stored fields
                self.storedFields["gezin"] = gezin
                
                # Check size of family
                if (len(gezin.persoon_set.all()) == 1):
                    # Can't process this as family
                    is_mode_family = False
                    # Store persoon separately
                    self.storedFields["persoon"] = gezin.persoon_set.get(pk=1)                
        else:
            # Extract persoon Id from url
            persoonId = kwargs["persoonId"]
        
            # Check if persoon already retrieved
            if ("persoon" not in self.storedFields 
                or self.storedFields["persoon"].idpersoon != persoonId):
                # Not yet retrieved or someone else. Retrieve.
                persoon = Persoon.objects.get(pk=persoonId)
            
                # Add persoon to stored fields
                self.storedFields["persoon"] = persoon
            
        self.storedFields["is_mode_family"] = is_mode_family

        # Copy data in stored fields to context        
        self.extra_context.update(self.storedFields)
        
        # Continue in super class
        FormWizard.parse_params(self, request, args, kwargs)
Exemplo n.º 2
0
 def parse_params(self, request, *args, **kwargs):
     """
     Extract the persoon from the url. To prevent this method from
     retrieving the same persoon in every screen we add a check to
     see if the persoon is already retrieved.
     """
     
     # Extract persoon ID from url
     persoonId = kwargs["persoonId"]
     
     # Check if persoon already retrieved
     if ("persoonA" not in self.storedFields 
         or self.storedFields["persoonA"].idpersoon != persoonId):
         # Not yet retrieved or someone else. Retrieve.
         persoon = Persoon.objects.get(pk=persoonId)
     
         # Add persoon to stored fields
         self.storedFields["persoonA"] = persoon        
     
     # Continue in super class
     FormWizard.parse_params(self, request, args, kwargs)