Ejemplo n.º 1
0
    def post(self, request):
        form = ContactForm(request.POST)

        if form.is_valid():
            form.save()

            return redirect(reverse('form') + "?ok")
Ejemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        context = self.get_context_data()

        if CONTACT_FORM_PREFIX in request.POST:
            contact_form = ContactForm(request.POST,
                                       prefix=CONTACT_FORM_PREFIX)
            context.update({'contact_form': contact_form})

            if contact_form.is_valid() and self.activity:
                contact = contact_form.save(self.activity)

                if contact:
                    messages.success(
                        request, _('Your message has been sent. Thank you.'))
                    context.update({
                        'contact_form':
                        ContactForm(prefix=CONTACT_FORM_PREFIX)
                    })

                    return super(HackathonView,
                                 self).render_to_response(context)

            messages.error(request,
                           _('Your message could not be sent. Try again.'))

        if SPEAKER_APPLICATION_FORM_PREFIX in request.POST:
            speaker_application_form = SpeakerApplicationForm(
                request.POST,
                request.FILES,
                prefix=SPEAKER_APPLICATION_FORM_PREFIX)
            context.update(
                {'speaker_application_form': speaker_application_form})

            if speaker_application_form.is_valid() and self.activity:
                speaker_application, created = speaker_application_form.save(
                    self.activity)

                if speaker_application:
                    if created:
                        messages.success(
                            request,
                            _('Your application has been sent. Thank you.'))

                        context.update({
                            'speaker_application_form':
                            SpeakerApplicationForm(
                                prefix=SPEAKER_APPLICATION_FORM_PREFIX)
                        })
                    else:
                        messages.error(request,
                                       _('Your application already exists!'))

                    return super(HackathonView,
                                 self).render_to_response(context)

            messages.error(request,
                           _('Your application could not be sent. Try again.'))

        return super(HackathonView, self).render_to_response(context)
Ejemplo n.º 3
0
    def get_context_data(self, **kwargs):
        context = super(HackathonView, self).get_context_data(**kwargs)

        if self.activity and self.hackathon:
            activity_sponsors = collections.OrderedDict()
            sponsors = self.activity.activitysponsor_set \
                .filter(is_active=True, sponsor_type__is_active=True) \
                .order_by('sponsor_type', 'order_id')
            for sponsor in sponsors:
                activity_sponsors.setdefault(sponsor.sponsor_type.name, []) \
                    .append(sponsor)

            context.update({
                'title': self.activity.short_description,
                'hackathon': self.hackathon,
                'hackathon_prizes': self.hackathon.hackathonprize_set\
                    .filter(is_active=True),
                'activity': self.activity,
                'activities': self.activities,
                'activity_document': self.activity.activitydocument_set \
                    .filter(is_active=True).first(),
                'activity_map': self.activity.activitymap_set \
                    .filter(is_active=True).first(),
                'activity_map_key': settings.GOOGLE_MAP_API_KEY,
                'activity_social_accounts': self.activity \
                    .activitysocialaccount_set.filter(is_active=True),
                'activity_sponsors': activity_sponsors,
                'contact_form': ContactForm(prefix=CONTACT_FORM_PREFIX),
                'speaker_application_form': SpeakerApplicationForm(
                    prefix=SPEAKER_APPLICATION_FORM_PREFIX
                )
            })

        return context
Ejemplo n.º 4
0
def contact(request):
    errors=[]
    if request.method=='POST':
	    form=ContactForm(request.POST)
	    if form.is_valid():
		    subject=form.cleaned_data['subject']
		    sender=form.cleaned_data['sender']
		    message=form.cleaned_data['message']
		    recipients = ['*****@*****.**']
		    send_mail(subject,message,sender,recipients)
		    return HttpResponseRedirect('/awaaz/contact/thankyou/')
    else:
	    form=ContactForm()
    return render_to_response('awaaz/cnt.html',{
	    'form':form,
	    },context_instance=RequestContext(request))
Ejemplo n.º 5
0
    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        if self.activity:
            activity_galleries = collections.OrderedDict()
            for gallery in self.activity.gallery_set.filter(is_active=True):
                activity_galleries.update({
                    gallery:
                    gallery.gallerycontent_set.filter(is_active=True)
                })

            activity_timeline = collections.OrderedDict()
            for program in self.activity.program_set.filter(is_active=True):
                activity_timeline.update({
                    program:
                    program.programcontent_set.filter(is_active=True)
                })

            activity_speakers = collections.OrderedDict()
            for speaker in self.activity.speakers.filter(is_active=True):
                activity_speakers.update({
                    speaker:
                    speaker.speakersocialaccount_set.filter(is_active=True)
                })

            activity_sponsors = collections.OrderedDict()
            sponsors = self.activity.activitysponsor_set \
                .filter(is_active=True, sponsor_type__is_active=True) \
                .order_by('sponsor_type', 'order_id')
            for sponsor in sponsors:
                activity_sponsors.setdefault(sponsor.sponsor_type.name, []) \
                    .append(sponsor)

            context.update({
                'title': self.activity.short_description,
                'activity': self.activity,
                'activities': self.activities,
                'hackathon': self.activity.hackathon_set.filter(is_active=True),
                'activity_document': self.activity.activitydocument_set \
                    .filter(is_active=True).first(),
                'activity_map': self.activity.activitymap_set \
                    .filter(is_active=True).first(),
                'activity_map_key': settings.GOOGLE_MAPS_API_KEY,
                'activity_social_accounts': self.activity \
                    .activitysocialaccount_set.filter(is_active=True),
                'activity_galleries': activity_galleries,
                'activity_timeline': activity_timeline,
                'activity_speakers': activity_speakers,
                'default_program_contents': DEFAULT_PROGRAM_CONTENTS,
                'activity_sponsors': activity_sponsors,
                'contact_form': ContactForm(prefix=CONTACT_FORM_PREFIX),
                'speaker_application_form': SpeakerApplicationForm(
                    prefix=SPEAKER_APPLICATION_FORM_PREFIX
                ),
                'register_form': RegisterForm(prefix=REGISTER_FORM_PREFIX)
            })

        return context
Ejemplo n.º 6
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            senderName = form.cleaned_data['sender_name']
            senderEmail = form.cleaned_data['sender_email']
            subject = form.cleaned_data['subject']
            message = form.cleaned_data['message']            

            recipients = ['*****@*****.**']

            try:
                send_mail('[ciscer contact]' + ' From: ' + senderName + ' - ' + ' Subject: ' + subject, message, senderEmail, recipients, fail_silently=False) 
            except e:
                return HttpResponseRedirect('/thank-you/?m=fail')
            return HttpResponseRedirect('/thank-you/?m=success')
            
    else:
        form = ContactForm() # An unbound form
        
    return render(request, 'contact.html', {
        'form': form,
    })
Ejemplo n.º 7
0
 def get(self, request):
     form = ContactForm()
     return render(request, self.template_name, {'form': form})
Ejemplo n.º 8
0
def contact_form():
    form = ContactForm()
    return {"form": form}