Exemplo n.º 1
0
def answer_question_done(request, election_instance_party_id, user_id):
    '''
        answer_question thanks page.
    '''
    check_permissions(request, election_instance_party_id, 'candidate')

    user = get_object_or_404(User, pk=user_id)

    message = None

    if request.method == 'POST':
        form = AgreeForm(data=request.POST)
        if form.is_valid():
            data = form.cleaned_data
            user.profile.hns_dev = data['hns_dev']
            user.profile.science = data['science']

            user.profile.save()

            message = _('Your preference has been saved')
    else:
        initial = {
            'hns_dev': user.profile.hns_dev,
            'science': user.profile.science,
        }
        form = AgreeForm(initial=initial)

    return render_to_response('backoffice/wizard/question/answer_add/done.html', {
                                'questions': range(0, get_question_count(election_instance_party_id)),
                                'eip_id': election_instance_party_id,
                                'user_id': user_id,
                                'form': form,
                                'message': message,
                            },
                            context_instance=RequestContext(request))
Exemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     # Getting "user_id"
     try:
         self.user_id = kwargs['user_id']
         self.political_id = kwargs['political_id']
         self.eip_id =  kwargs['eip_id']
         self.election_instance_party = get_object_or_404(ElectionInstanceParty, pk=self.eip_id)
         self.user = get_object_or_404(self.election_instance_party.candidates, candidate__pk=self.user_id).candidate
         
         if self.political_id:
             self.political = self.user.profile.political.get(pk=self.political_id)
         else:
             self.political = None
         
     except Exception:
         raise
     step1_forms = dict(political=PoliticalExperienceForm,)
     step1 = Step('candidate_edit_political',
                 forms=step1_forms,
                 template='backoffice/wizard/politician_profile/political-add.html',
                 initial={'political': self.political },
                 extra_context={'questions': range(0, get_question_count(self.election_instance_party)),
                 'eip_id': self.eip_id, 'user_id': self.user_id},
                 )
     scenario_tree = step1
     #default template is the base, each step can override it as needed (for buttons)
     template = 'backoffice/wizard/politician_profile/base.html',
     super(PoliticianProfilePoliticalWizard, self).__init__(scenario_tree, template)
Exemplo n.º 3
0
def politician_profile_setup_done(request, eip_id, user_id):
    check_permissions(request, eip_id, 'candidate')
    return render_to_response('backoffice/wizard/politician_profile/done.html',
                              {'user_id': user_id,
                              'eip_id': eip_id,
                              'questions': range(0, get_question_count(eip_id)),
                              },
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
def politician_profile_setup_done(request, eip_id, user_id):
    check_permissions(request, eip_id, 'candidate')
    return render_to_response(
        'backoffice/wizard/politician_profile/done.html', {
            'user_id': user_id,
            'eip_id': eip_id,
            'questions': range(0, get_question_count(eip_id)),
        },
        context_instance=RequestContext(request))
Exemplo n.º 5
0
def politician_profile_appearance(request, eip_id, user_id):
    check_permissions(request, eip_id, 'candidate')
    user = get_object_or_404(User, pk=user_id)
    appearances = user.profile.appearances.all()
    return render_to_response('backoffice/wizard/politician_profile/appearances.html',
                              {'user_id': user_id, 'appearances': appearances,
                              'eip_id': eip_id,
                              'questions': range(0, get_question_count(eip_id)),
                              },
                              context_instance=RequestContext(request))
Exemplo n.º 6
0
def politician_profile_appearance(request, eip_id, user_id):
    check_permissions(request, eip_id, 'candidate')
    user = get_object_or_404(User, pk=user_id)
    appearances = user.profile.appearances.all()
    return render_to_response(
        'backoffice/wizard/politician_profile/appearances.html', {
            'user_id': user_id,
            'appearances': appearances,
            'eip_id': eip_id,
            'questions': range(0, get_question_count(eip_id)),
        },
        context_instance=RequestContext(request))
Exemplo n.º 7
0
def politician_welcome(request, eip_id):
    check_permissions(request, eip_id, 'candidate')
    election_instance_party = get_object_or_404(ElectionInstanceParty, pk=eip_id)
    if not request.user.profile or request.user.profile.type != 'candidate':
        raise PermissionDeniedException('Geen toegang met de huidige account')
    else:
        user = get_object_or_404(election_instance_party.candidates, candidate=request.user).candidate

    return render_to_response('backoffice/wizard/politician_profile/welcome.html',
                              {'user_id': user.id,
                              'politician': user.profile,
                              'election_instance': election_instance_party.election_instance,
                              'eip_id': eip_id,
                              'questions': range(0, get_question_count(eip_id)),
                              },
                              context_instance=RequestContext(request))
Exemplo n.º 8
0
def politician_welcome(request, eip_id):
    check_permissions(request, eip_id, 'candidate')
    election_instance_party = get_object_or_404(ElectionInstanceParty,
                                                pk=eip_id)
    if not request.user.profile or request.user.profile.type != 'candidate':
        raise PermissionDeniedException('Geen toegang met de huidige account')
    else:
        user = get_object_or_404(election_instance_party.candidates,
                                 candidate=request.user).candidate

    return render_to_response(
        'backoffice/wizard/politician_profile/welcome.html', {
            'user_id': user.id,
            'politician': user.profile,
            'election_instance': election_instance_party.election_instance,
            'eip_id': eip_id,
            'questions': range(0, get_question_count(eip_id)),
        },
        context_instance=RequestContext(request))
Exemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        # Getting "user_id"
        try:
            self.user_id = kwargs['user_id']
            self.connection_id = kwargs['connection_id']
            self.eip_id = kwargs['eip_id']
            self.election_instance_party = get_object_or_404(
                ElectionInstanceParty, pk=self.eip_id)
            self.user = get_object_or_404(
                self.election_instance_party.candidates,
                candidate__pk=self.user_id).candidate

            if self.connection_id:
                self.connection = self.user.profile.connections.get(
                    pk=self.connection_id)
            else:
                self.connection = None

        except Exception:
            raise

        step1_forms = dict(connection=ConnectionForm, )
        step1 = Step(
            'candidate_edit_connection',
            forms=step1_forms,
            template=
            'backoffice/wizard/politician_profile/connections-add.html',
            initial={'connection': self.connection},
            extra_context={
                'questions':
                range(0, get_question_count(self.election_instance_party)),
                'eip_id':
                self.eip_id,
                'user_id':
                self.user_id
            },
        )
        scenario_tree = step1
        #default template is the base, each step can override it as needed (for buttons)
        template = 'backoffice/wizard/politician_profile/base.html',
        super(PoliticianProfileConnectionWizard,
              self).__init__(scenario_tree, template)
Exemplo n.º 10
0
def answer_question_done(request, election_instance_party_id, user_id):
    '''
        answer_question thanks page.
    '''
    check_permissions(request, election_instance_party_id, 'candidate')

    user = get_object_or_404(User, pk=user_id)

    message = None

    if request.method == 'POST':
        form = AgreeForm(data=request.POST)
        if form.is_valid():
            data = form.cleaned_data
            user.profile.hns_dev = data['hns_dev']
            user.profile.science = data['science']

            user.profile.save()

            message = _('Your preference has been saved')
    else:
        initial = {
            'hns_dev': user.profile.hns_dev,
            'science': user.profile.science,
        }
        form = AgreeForm(initial=initial)

    return render_to_response(
        'backoffice/wizard/question/answer_add/done.html', {
            'questions': range(0,
                               get_question_count(election_instance_party_id)),
            'eip_id': election_instance_party_id,
            'user_id': user_id,
            'form': form,
            'message': message,
        },
        context_instance=RequestContext(request))
Exemplo n.º 11
0
    def __init__(self, *args, **kwargs):
        # Getting "user_id"
        try:
            self.user_id = kwargs['user_id']
            self.eip_id = kwargs['eip_id']

            self.election_instance_party = get_object_or_404(
                ElectionInstanceParty, pk=self.eip_id)
            self.user = get_object_or_404(
                self.election_instance_party.candidates,
                candidate__pk=self.user_id).candidate

            if self.user.profile is None or self.user.profile.type != 'candidate':
                raise PermissionDeniedException('Wrong profile type')

            self.user_profile_dict = {
                'name': {
                    'first_name': self.user.profile.first_name,
                    'middle_name': self.user.profile.middle_name,
                    'last_name': self.user.profile.last_name,
                },
                'email': self.user.email,
                'initials': self.user.profile.initials,
                'dateofbirth': self.user.profile.dateofbirth,
                'introduction': self.user.profile.introduction,
                'gender': self.user.profile.gender,
                'picture': self.user.profile.picture,
                'movie': self.user.profile.movie,
                'marital_status': self.user.profile.marital_status,
                'num_children': self.user.profile.num_children,
                'religion': self.user.profile.religion,
                'religious_group': self.user.profile.religious_group,
                'province': self.user.profile.province,
                'smoker': self.user.profile.smoker,
                'diet': self.user.profile.diet,
                'fav_news': self.user.profile.fav_news,
                'transport': self.user.profile.transport,
                'charity': self.user.profile.charity,
                'fav_media': self.user.profile.fav_media,
                'fav_sport': self.user.profile.fav_sport,
                'hobby': self.user.profile.hobby,
                'fav_club': self.user.profile.fav_club,
                'fav_pet': self.user.profile.fav_pet,
            }

        except Exception:
            raise

        step1_forms = dict(initial_candidate=PoliticianProfileForm)
        step2_forms = dict(life_candidate=PoliticianProfileLifeForm)
        step3_forms = dict(extra_candidate=PoliticianProfileExtraForm)
        step4_forms = dict(political_candidate=PoliticianProfilePoliticalForm)
        step1 = Step(
            'initial_candidate',
            forms=step1_forms,
            template='backoffice/wizard/politician_profile/step1.html',
            initial={'initial_candidate': self.user_profile_dict},
            extra_context={
                'questions':
                range(0, get_question_count(self.election_instance_party)),
                'eip_id':
                self.eip_id,
                'user_id':
                self.user_id
            },
        )
        step2 = Step(
            'life_candidate',
            forms=step2_forms,
            template='backoffice/wizard/politician_profile/step2.html',
            initial={'life_candidate': self.user_profile_dict},
            extra_context={
                'questions':
                range(0, get_question_count(self.election_instance_party)),
                'eip_id':
                self.eip_id,
                'user_id':
                self.user_id
            },
        )
        step3 = Step(
            'extra_candidate',
            forms=step3_forms,
            template='backoffice/wizard/politician_profile/step3.html',
            initial={'extra_candidate': self.user_profile_dict},
            extra_context={
                'questions':
                range(0, get_question_count(self.election_instance_party)),
                'eip_id':
                self.eip_id,
                'user_id':
                self.user_id
            },
        )
        step4 = Step(
            'political_candidate',
            forms=step4_forms,
            template='backoffice/wizard/politician_profile/step4.html',
            initial={'political_candidate': self.user_profile_dict},
            extra_context={
                'questions':
                range(0, get_question_count(self.election_instance_party)),
                'eip_id':
                self.eip_id,
                'user_id':
                self.user_id
            },
        )

        scenario_tree = step1.next(step2.next(step3.next(step4)))
        #default template is the base, each step can override it as needed (for buttons)

        template = 'backoffice/wizard/politician_profile/base.html',
        super(PoliticianProfileWizard, self).__init__(scenario_tree, template)
Exemplo n.º 12
0
    def __init__(self, *args, **kwargs):
        # Getting "user_id"
        try:
            self.user_id = kwargs['user_id']
            self.eip_id =  kwargs['eip_id']
            
            self.election_instance_party = get_object_or_404(ElectionInstanceParty, pk=self.eip_id)
            self.user = get_object_or_404(self.election_instance_party.candidates, candidate__pk=self.user_id).candidate

            if self.user.profile is None or self.user.profile.type != 'candidate':
                raise PermissionDeniedException('Wrong profile type')

            self.user_profile_dict = {
                'name': {'first_name': self.user.profile.first_name, 'middle_name': self.user.profile.middle_name, 'last_name': self.user.profile.last_name, },
                'email': self.user.email,
                'initials': self.user.profile.initials,
                'dateofbirth': self.user.profile.dateofbirth,
                'introduction': self.user.profile.introduction,
                'gender': self.user.profile.gender,
                'picture': self.user.profile.picture,
                'movie': self.user.profile.movie,

                'marital_status': self.user.profile.marital_status,
                'num_children': self.user.profile.num_children,
                'religion': self.user.profile.religion,
                'religious_group': self.user.profile.religious_group,
                'province': self.user.profile.province,
                'smoker': self.user.profile.smoker,
                'diet': self.user.profile.diet,
                'fav_news': self.user.profile.fav_news,
                'transport': self.user.profile.transport,
                'charity': self.user.profile.charity,
                'fav_media': self.user.profile.fav_media,
                'fav_sport': self.user.profile.fav_sport,
                'hobby': self.user.profile.hobby,
                'fav_club': self.user.profile.fav_club,
                'fav_pet': self.user.profile.fav_pet,

            }
            
        except Exception:
            raise

        step1_forms = dict(initial_candidate = PoliticianProfileForm)
        step2_forms = dict(life_candidate = PoliticianProfileLifeForm)
        step3_forms = dict(extra_candidate = PoliticianProfileExtraForm)
        step4_forms = dict(political_candidate = PoliticianProfilePoliticalForm)
        step1 = Step('initial_candidate',
                    forms=step1_forms,
                    template='backoffice/wizard/politician_profile/step1.html',
                    initial={'initial_candidate': self.user_profile_dict },
                    extra_context={'questions': range(0, get_question_count(self.election_instance_party)),
                    'eip_id': self.eip_id, 'user_id': self.user_id},
                    )
        step2 = Step('life_candidate',
                    forms=step2_forms,
                    template='backoffice/wizard/politician_profile/step2.html',
                    initial={'life_candidate': self.user_profile_dict },
                    extra_context={'questions': range(0, get_question_count(self.election_instance_party)),
                    'eip_id': self.eip_id, 'user_id': self.user_id},
                    )
        step3 = Step('extra_candidate',
                    forms=step3_forms,
                    template='backoffice/wizard/politician_profile/step3.html',
                    initial={'extra_candidate': self.user_profile_dict },
                    extra_context={'questions': range(0, get_question_count(self.election_instance_party)),
                    'eip_id': self.eip_id, 'user_id': self.user_id},
                    )
        step4 = Step('political_candidate',
                    forms=step4_forms,
                    template='backoffice/wizard/politician_profile/step4.html',
                    initial={'political_candidate': self.user_profile_dict },
                    extra_context={'questions': range(0, get_question_count(self.election_instance_party)),
                    'eip_id': self.eip_id, 'user_id': self.user_id},
                    )
                
        scenario_tree = step1.next(step2.next(step3.next(step4)))
        #default template is the base, each step can override it as needed (for buttons)

        template = 'backoffice/wizard/politician_profile/base.html',
        super(PoliticianProfileWizard, self).__init__(scenario_tree, template)