Пример #1
0
def subscriber(request):
    response = HttpResponse()
    
    f = SubscriberForm(request.POST)
    if f.is_valid():
        subscriber = f.save(commit=False)
        
        sub_objs = Subscriber.objects.filter(email_address=subscriber.email_address)
        if sub_objs.count() == 0:
            subscriber.enabled = True
            subscriber.save()
            
            response.write("1")
        elif sub_objs.count() == 1:
            subscriber = sub_objs[0]
            
            if not subscriber.enabled:
                subscriber.enabled = True
                subscriber.save()
                
                response.write("1")
            else:
                response.write("0")
        else:
            response.write("0")
    else:
        response.write("0")
    
    return response
Пример #2
0
def home(request):
    songs = Song.objects.all().order_by("-frequency")
    mp_int = Interview.objects.all().order_by("-frequency").first()
    mr_int = Interview.objects.all().first()
    mp_stu = StudioExclusive.objects.all().order_by("-frequency").first()
    mr_stu = StudioExclusive.objects.all().first()
    mr_alb = Album.objects.all().first()
    mr_band = Band.objects.all().first()
    subscribe_form = SubscriberForm(request.POST or None)
    stuexc_form = FeaturedForm(request.POST or None, request.FILES or None)

    if 'message' in request.POST:
        if stuexc_form.is_valid():
            instance1 = stuexc_form.save(commit=False)
            instance1.save()
            # print instance1.cleaned_data
            return redirect('home')
    else:
        if subscribe_form.is_valid():
            instance = subscribe_form.save(commit=False)
            instance.save()
            return redirect('home')

    return render(
        request, "base.html", {
            "songs": songs,
            "stu_obj": mp_stu,
            "int_freq": mp_int,
            "int_rec": mr_int,
            "stu_rec": mr_stu,
            "alb_rec": mr_alb,
            "band_rec": mr_band,
            "subscribe_form": subscribe_form,
            "stuexc_form": stuexc_form,
        })
Пример #3
0
def subscribe(request):
    errors = None
    if request.POST:
        d = request.POST
        subscriber_data = {
            "first_name": d["firstName"],
            "last_name": d["lastName"],
            "email": d["email"],
            "tel_no": d["tel"],
            "cell_no": d["cell"],
            "address": d["address"],
            "street": d["street"],
            "city": d["city"],
            "zip_code": d["zip"],
            "state": d["state"],
            "country": d["country"],
            "role": d["role"],
        }
        subscriber_form = SubscriberForm(subscriber_data)
        # import pdb;pdb.set_trace()
        if subscriber_form.is_valid():
            subscriber_form.save()
            helpers.send_ack_email(subscriber_data)
            helpers.send_admin_email(subscriber_data)
            return HttpResponseRedirect("/subscribe_thanks")
        else:
            errors = subscriber_form.errors
            # return render(request, "subscribe.html", {'form': subscriber_form})

    return render(request, "subscribe.html", {"errors": errors})
Пример #4
0
def addSub(request):
	if not views.if_authenticated():
		t = loader.get_template('login.html')
		c = RequestContext(request)
		return HttpResponse(t.render(c))
	form = SubscriberForm(request.POST)
	if request.method == "POST" and form.is_valid():
    	sub_details = Subscriber.objects.create(
				sid = form.cleaned_data['sid'],
				name = form.cleaned_data['name'],
				gender = form.cleaned_data['gender'],
				contact = form.cleaned_data['contact'],
				mail = form.cleaned_data['mail'],
				NoOfBooks = 0
				)
		sub_details.save()
		text = 'Subscriber added Successfully'
		t = loader.get_template('success.html')
		c = RequestContext(request, { 'text' : text })
		return HttpResponse(t.render(c))
	else:
		t = loader.get_template('add.html')
		text = 'Add Subscriber'
		c = RequestContext(request , { 'form' : form , 'text' : text})
		return HttpResponse(t.render(c))
Пример #5
0
def subscribe(request):
    if request.method == "POST":
        form = SubscriberForm(request.POST)
        if form.is_valid():
            if form.clean_email():
                form.save()
                return redirect("/")
        return {'user_form': form}
    return {'user_form': SubscriberForm()}
Пример #6
0
def createSubscriber(request):
    if request.POST:
        form = SubscriberForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/subscriber_successful')
    else:
        form = SubscriberForm()
    args = {}
    args.update(csrf(request))

    args['form'] = form
    return render_to_response('Subscribe.html', args)
Пример #7
0
def addSubscriber(request):
	form = SubscriberForm(request.POST)
	if form.is_valid():
		subscriber = Subscriber(email=form.clean_data['email'])
		subscriber.put()
		message = mail.EmailMessage(sender=u"DunTeam <*****@*****.**>", subject=u"Дагасанд баярлалаа")
		message.to = subscriber.email
		message.body = u"Баярлалаа\nТа бидний шинэ мэдээг дагахаар амжилттай бүртгүүллээ.\nDunTeam"
		message.send()
	else:
		return render_to_response('index.html', {'form': form })

	return HttpResponseRedirect('/')
Пример #8
0
def createSubscriber(request):
    if request.POST:
        form = SubscriberForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/subscriber_successful')
    else:
        form = SubscriberForm()
    args = {}
    args.update(csrf(request))

    args['form'] = form
    return render_to_response('Subscribe.html', args)
Пример #9
0
def home(request):
    errorMsg = ''
    successMsg = ''

    if request.method == 'POST':
        form = SubscriberForm(request.POST, request.FILES)
        if form.is_valid():
            actualEmail = request.POST['email']
            user = Subscriber.objects.filter(email=actualEmail)
            if len(user) == 0:
                subscriber = form.save()
                user = Subscriber.objects.get(email=actualEmail)
                successMsg = 'Gracias por registrarte, pronto estarás recibiendo noticias.'

            else:
                errorMsg = 'Gracias por registrarte, pronto estarás recibiendo noticias.'

                form = SubscriberForm()
    else:

        form = SubscriberForm()

    groups = []
    a = Team.objects.filter(group='A')
    b = Team.objects.filter(group='B')
    c = Team.objects.filter(group='C')
    d = Team.objects.filter(group='D')
    e = Team.objects.filter(group='E')
    f = Team.objects.filter(group='F')
    g = Team.objects.filter(group='G')
    h = Team.objects.filter(group='H')

    groups.append(a)
    groups.append(b)
    groups.append(c)
    groups.append(d)
    groups.append(e)
    groups.append(f)
    groups.append(g)
    groups.append(h)

    return render(
        request, 'index.html', {
            'groups': groups,
            'form': form,
            'errorMessage': errorMsg,
            'successMessage': successMsg
        })
Пример #10
0
def home(request):
    errorMsg = ''
    successMsg = ''

    if request.method == 'POST':
        form = SubscriberForm(request.POST, request.FILES)
        if form.is_valid():
            actualEmail = request.POST['email']
            user = Subscriber.objects.filter(email=actualEmail)
            if len(user) == 0:
                subscriber = form.save()
                user = Subscriber.objects.get(email=actualEmail)
                successMsg = 'Gracias por registrarte, pronto estarás recibiendo noticias.'

            else:
                errorMsg = 'Gracias por registrarte, pronto estarás recibiendo noticias.'

                form = SubscriberForm()
    else    :

        form = SubscriberForm()
    
    groups = []
    a = Team.objects.filter(group = 'A')
    b = Team.objects.filter(group = 'B')
    c = Team.objects.filter(group = 'C')
    d = Team.objects.filter(group = 'D')
    e = Team.objects.filter(group = 'E')
    f = Team.objects.filter(group = 'F')
    g = Team.objects.filter(group = 'G')
    h = Team.objects.filter(group = 'H')

    groups.append(a)
    groups.append(b)
    groups.append(c)
    groups.append(d)
    groups.append(e)
    groups.append(f)
    groups.append(g)
    groups.append(h)

    return render(request, 'index.html',{ 'groups':groups, 'form':form, 'errorMessage':errorMsg, 'successMessage':successMsg})
Пример #11
0
    def get(self, request, *args, **kwargs):
        form = SubscriberForm(request.GET)
        if not form.is_valid():
            return HttpResponse(json.dumps({
                'success': False,
                'validation_error': True,
                'message': form.errors,
                'form_error': True
            }),
                                content_type="application/json",
                                status=200)

        with LdapHandler(request.session['host_address'],
                         request.session['port_number'],
                         request.session['username'],
                         request.session['password'],
                         request.session['scope_subtree']) as ldap_handler:
            profiles = ldap_handler.search(form.cleaned_data['subscriber_id'])
            return HttpResponse(json.dumps({
                'success': True,
                'profiles': profiles
            }),
                                content_type="application/json",
                                status=200)