Beispiel #1
0
def change_current_role(request, entity_type=None, entity_id=None):
    if not entity_type or not entity_id:
        role_controller = RoleController(request.user)
        role = select_most_appropriate_user_role(role_controller)
        entity_type = role.entity_type
        entity_id = role.entity.id
    else:
        role = RoleController.GetRoleForEntityTypeAndID(
            entity_type, entity_id,
            RoleBase.EntityWrapperByEntityType(entity_type))
    request.session['current_role'] = {
        'entity_type': entity_type,
        'entity_id': entity_id
    }
    return role
def challenge_view(request, challenge_id):
    challenge = get_object_or_404(Challenge, id=challenge_id)
    template = challenge.template
    template_data = {
        'challenge':
        challenge,
        'template':
        template,
        'owner':
        RoleController.GetRoleForEntityTypeAndID(
            challenge.creator_entity_type, challenge.creator_entity_id,
            RoleBase.EntityWrapperByEntityType(challenge.creator_entity_type))
    }
    return render(request, 'spudderspuds/challenges/pages/challenge_view.html',
                  template_data)
Beispiel #3
0
 def creator(self):
     attribute_key = '_creator'
     try:
         creator = getattr(self, attribute_key)
         if not creator:
             raise AttributeError
     except AttributeError:
         from spudderaccounts.controllers import RoleController
         from spudderaccounts.wrappers import RoleBase
         creator = None
         for entity_type in RoleController.ENTITY_TYPES:
             if self.creator_entity_type == entity_type:
                 creator = RoleController.GetRoleForEntityTypeAndID(
                     entity_type, self.creator_entity_id,
                     RoleBase.EntityWrapperByEntityType(entity_type))
         setattr(self, attribute_key, creator)
     return creator
def challenge_challenge_thanks(request, participation_id):
    participation = get_object_or_404(ChallengeChallengeParticipation,
                                      id=participation_id)
    creator = RoleController.GetRoleForEntityTypeAndID(
        participation.participating_entity_type,
        participation.participating_entity_id,
        RoleBase.EntityWrapperByEntityType(
            participation.participating_entity_type))
    beneficiary = EntityController.GetWrappedEntityByTypeAndId(
        participation.recipient_entity_type, participation.recipient_entity_id,
        EntityBase.EntityWrapperByEntityType(
            participation.recipient_entity_type))
    template_data = {
        'participation': participation,
        'creator': creator,
        'beneficiary': beneficiary,
        'just_submitted': request.GET.get('just_submitted')
    }
    return render(
        request,
        'spudderspuds/challenges/pages/challenge_challenge_thanks.html',
        template_data)