Beispiel #1
0
 def test_create_organization_form(self):
     data = {'username': '******',
             'name': 'This Is a Great Group',
             'email': '*****@*****.**',
             'password1': 'pass',
             'password2': 'pass',
             }
     form = GroupCreationForm(data=data)
     self.assertTrue(form.is_valid())
     group = form.save()
     self.assertEquals(group.first_name, data['name'])
     self.assertTrue(group.profile.is_organization)
Beispiel #2
0
 def test_get_group_register_form(self):
     template_str = get_template('login/group_register.html')
     form = GroupCreationForm()
     rendered_template = template_str.render(Context({'form': form}))
     template = Template(
         "{% load votainteligente_extras %}{% group_register %}")
     self.assertEqual(template.render(Context({})), rendered_template)
Beispiel #3
0
    def get_context_data(self, **kwargs):
        context = super(HomeView, self).get_context_data(**kwargs)
        context['form'] = ElectionSearchByTagsForm()

        featured_elections = cache.get('featured_elections')
        if featured_elections is None:
            featured_elections = Election.objects.filter(highlighted=True)
            cache.set('featured_elections', featured_elections, 600)
        context['featured_elections'] = featured_elections

        context['searchable_elections_enabled'] = True
        context['register_new_form'] = RegistrationForm()
        context['login_form'] = AuthenticationForm()
        context['group_login_form'] = GroupCreationForm()
        total_proposals = cache.get('total_proposals')
        if total_proposals is None:
            total_proposals = PopularProposal.objects.count()
            cache.set('total_proposals', total_proposals, 600)
        context['total_proposals'] = total_proposals
        proposals_with_likers = cache.get('proposals_with_likers')
        if proposals_with_likers is None:
            proposals_with_likers = PopularProposal.ordered.by_likers()[:9]
            cache.set('proposals_with_likers', proposals_with_likers, 600)
        context['proposals_with_likers'] = proposals_with_likers
        return context
 def test_organization_form_with_terms_and_conditions(self):
     data = {'username': '******',
             'name': 'This Is a Great Group',
             'email': '*****@*****.**',
             'password1': 'pass',
             'password2': 'pass',
             'terms_and_conditions': False
             }
     form = GroupCreationForm(data=data)
     self.assertFalse(form.is_valid())
     data['terms_and_conditions'] = True
     form = GroupCreationForm(data=data)
     self.assertTrue(form.is_valid())
     group = form.save()
     self.assertEquals(group.last_name, data['name'])
     self.assertTrue(group.profile.is_organization)
Beispiel #5
0
 def test_organization_form_with_terms_and_conditions(self):
     data = {'username': '******',
             'name': 'This Is a Great Group',
             'email': '*****@*****.**',
             'password1': 'passpasspasspass',
             'password2': 'passpasspasspass',
             'terms_and_conditions': False
             }
     form = GroupCreationForm(data=data)
     self.assertFalse(form.is_valid())
     data['terms_and_conditions'] = True
     form = GroupCreationForm(data=data)
     self.assertTrue(form.is_valid())
     group = form.save()
     self.assertEquals(group.last_name, data['name'])
     self.assertTrue(group.profile.is_organization)
Beispiel #6
0
    def get_context_data(self, **kwargs):
        context = super(HomeView, self).get_context_data(**kwargs)
        context['form'] = ElectionSearchByTagsForm()

        featured_elections = cache.get('featured_elections')
        if featured_elections is None:
            featured_elections = Election.objects.filter(highlighted=True)
            cache.set('featured_elections', featured_elections, 600)
        context['featured_elections'] = featured_elections

        context['searchable_elections_enabled'] = True
        context['register_new_form'] = RegistrationForm()
        context['login_form'] = AuthenticationForm()
        context['group_login_form'] = GroupCreationForm()
        total_proposals = cache.get('total_proposals')
        if total_proposals is None:
            total_proposals = PopularProposal.objects.count()
            cache.set('total_proposals', total_proposals, 600)
        context['total_proposals'] = total_proposals
        proposals_with_likers = cache.get('proposals_with_likers')
        if proposals_with_likers is None:
            proposals_with_likers = PopularProposal.ordered.by_likers()[:9]
            cache.set('proposals_with_likers', proposals_with_likers, 600)
        context['proposals_with_likers'] = proposals_with_likers
        featured_proposals = cache.get('featured_proposals')
        if featured_proposals is None:
            featured_proposals = PopularProposal.objects.filter(
                featured=True).filter(
                    content_type__app_label="popular_proposal")
            cache.set('featured_proposals', featured_proposals, 600)
        context['featured_proposals'] = featured_proposals
        featured_candidates = cache.get('featured_candidates')
        if featured_candidates is None:
            featured_candidates = Candidate.objects.filter(
                commitments__isnull=False).filter(
                    elections__name="Presidencia")
            cache.set('featured_candidates', featured_candidates)
        context['candidates'] = featured_candidates
        return context
Beispiel #7
0
def group_register():
    form = GroupCreationForm()
    return {'form': form}