Exemple #1
0
def iletisim(request):
    if not request.user.is_authenticated:
        return Http404()

    form = ContactForm(request.POST or None)

    if form.is_valid():
        contact = form.save(commit=False)
        contact.save()
        messages.success(request,
                         "Başarılı bir şekilde oluşturdunuz.",
                         extra_tags='mesaj-basarili')
        return HttpResponseRedirect(reverse('iletisim'))

    return render(request, 'post/contact.html')
Exemple #2
0
class Search(View):
    template_name = 'en/search.html'
    merop = GlavCategory.objects.get(name__icontains=u'Наши проекты')
    context = {
        'assosiations':
        OFonde.objects.filter(language__name__icontains='en').first(),
        'navbar':
        merop.category_set.filter(language__name__icontains=u'en'),
        'anonsy':
        Category.objects.get(name__icontains=u'Анонсы'),
        'articles_4':
        New.objects.filter(language__name__icontains='en',
                           category__name__icontains=u'Жаңылыктар',
                           is_public=True).order_by('-id')[:5],
        'form':
        ContactForm(),
    }

    # context = {}

    def get(self, request):
        self.context['h2'] = 'SEARCH'
        self.context['text'] = 'We searched, but you!'

        q = request.GET.get('q')
        if q:
            self.context['posts'] = New.objects.filter(
                name__icontains=q, language__name__icontains='en')
        else:
            self.context['posts'] = ''
        # return context
        return render(request, self.template_name, self.context)
Exemple #3
0
def contact_form(request):
    sent = False
    mailto = ['*****@*****.**']
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            phone = form.cleaned_data['phone']
            subject = u'МАПЭФ - Новое письмо от {}'.format(name)
            message = u'Емайл: {}. Телефон: {}'.format(email, phone)
            sent = True
            try:
                send_mail(subject, message, '*****@*****.**', mailto)
            except BadHeaderError:  # Защита от уязвимости
                return HttpResponse('Invalid header found')
            return redirect(u'en_news_list')
    else:
        form = ContactForm()
    return render(request, 'en/index.html', {'forms': form, 'sent': sent})
Exemple #4
0
 def get_context_data(self, *args, **kwargs):
     context = super(Navbar, self).get_context_data(**kwargs)
     merop = GlavCategory.objects.get(name__icontains=u'Наши проекты')
     context['navbar'] = merop.category_set.filter(
         language__name__icontains=u'en')
     context['anonsy'] = Category.objects.get(name__icontains=u'Анонсы')
     context['articles_4'] = New.objects.filter(
         language__name__icontains='en',
         category__name__icontains=u'Жаңылыктар',
         is_public=True).order_by('-id')[:5]
     context['form'] = ContactForm()
     context['assosiations'] = OFonde.objects.filter(
         language__name__icontains='en').first()
     return context
def Contact(request):

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            message = form.save(commit=False)
            message.message_date = timezone.now()
            form.save()
            return redirect('contactsuccess')
    else:
        form = ContactForm()

    context = {
        'form': form,
    }

    return render(request, 'contact.html', context)