Example #1
0
def legal(request):
    data = shared_context(request, tags=["legal"])

    try:
        data['page'] = Page.objects.get(slug="legal-notice",
                                        language=data['language'])
    except Page.DoesNotExist:
        p_en = Page(title="Legal", language='EN', slug="legal-notice")
        p_en.save()

        p_fr = Page(title="Mentions légales",
                    language='FR',
                    slug="legal-notice")
        p_fr.save()

        data['page'] = p_fr if data['language'] == 'FR' else p_en

    # load all pins without page
    data['pins'] = Pin.objects.filter(
        language=data['language'], page__slug="legal-notice").order_by("-id")

    # get news
    # data['news'] = Pin.objects.filter(language=data['language'], page__isnull=True, status=Pin.published ).order_by("-id")

    return render_to_response("%s/legal.html" % data['template'],
                              RequestContext(request, data))
Example #2
0
def pages(request):
    # logger.info("Welcome to GLUEBOX api")
    response = Epoxy(request)
    if response.method == 'POST':
        form = AddPageForm(request.REQUEST)
        if not form.is_valid():
            return response.throw_error(error=form.errors,
                                        code=API_EXCEPTION_FORMERRORS).json()
        try:
            p_en = Page(title=form.cleaned_data['title_en'],
                        language='EN',
                        slug=form.cleaned_data['slug'])
            p_en.save()

            p_fr = Page(title=form.cleaned_data['title_fr'],
                        language='FR',
                        slug=form.cleaned_data['slug'])
            p_fr.save()
        except IntegrityError, e:
            return response.throw_error(error="%s" % e,
                                        code=API_EXCEPTION_INTEGRITY).json()

        response.add('object', [p_en.json(), p_fr.json()])
Example #3
0
def pages(request):
	# logger.info("Welcome to GLUEBOX api")
	response = Epoxy( request )
	if response.method =='POST':
		form = AddPageForm( request.REQUEST )
		if not form.is_valid():
			return response.throw_error( error=form.errors, code=API_EXCEPTION_FORMERRORS).json()
		try:
			p_en = Page( title=form.cleaned_data['title_en'], language='EN', slug=form.cleaned_data['slug'])
			p_en.save()

			p_fr = Page( title=form.cleaned_data['title_fr'], language='FR', slug=form.cleaned_data['slug'])
			p_fr.save() 
		except IntegrityError, e:
			return response.throw_error( error="%s" % e, code=API_EXCEPTION_INTEGRITY).json()

		response.add('object',[ p_en.json(), p_fr.json() ])
Example #4
0
def index(request):
    data = shared_context(request, tags=["index"])

    try:
        data['page'] = Page.objects.get(slug="index",
                                        language=data['language'])
    except Page.DoesNotExist:
        p_en = Page(title="Home Page", language='EN', slug="index")
        p_en.save()

        p_fr = Page(title="Home Page", language='FR', slug="index")
        p_fr.save()

        data['page'] = p_fr if data['language'] == 'FR' else p_en

    # load all pins without page
    data['pins'] = Pin.objects.filter(language=data['language'],
                                      page__slug="index").order_by("-id")

    # get news
    data['news'] = _get_news(data)

    return render_to_response("%s/index.html" % data['template'],
                              RequestContext(request, data))
Example #5
0
def enquiries(request):

    data = shared_context(request, tags=["enquiries"])

    try:
        data['page'] = Page.objects.get(slug="enquiries",
                                        language=data['language'])
    except Page.DoesNotExist:
        p_en = Page(title="studies on studies",
                    language='EN',
                    slug="enquiries")
        p_en.save()

        p_fr = Page(title="enquêtes sur les enquêtes",
                    language='FR',
                    slug="enquiries")
        p_fr.save()

        data['page'] = p_fr if data['language'] == 'FR' else p_en

    data['enquiries'] = Enquiry.objects.filter(language=data['language'])

    return render_to_response('enquete/enquiries.html',
                              RequestContext(request, data))
Example #6
0
def enquiries( request ):

	data = shared_context( request, tags=[ "enquiries" ] )
	
	try:
		data['page'] = Page.objects.get( slug="enquiries", language=data['language'])
	except Page.DoesNotExist:
		p_en = Page( title="studies on studies", language='EN', slug="enquiries")
		p_en.save()

		p_fr = Page( title="enquêtes sur les enquêtes", language='FR', slug="enquiries")
		p_fr.save()

		data['page'] = p_fr if data['language'] == 'FR' else p_en

	data['enquiries'] = Enquiry.objects.filter( language=data['language'] )

	return render_to_response('enquete/enquiries.html', RequestContext(request, data ) )
Example #7
0
def index( request ):
	data = shared_context( request, tags=[ "index" ] )
	
	try:
		data['page'] = Page.objects.get( slug="index", language=data['language'])
	except Page.DoesNotExist:
		p_en = Page( title="Home Page", language='EN', slug="index")
		p_en.save()

		p_fr = Page( title="Home Page", language='FR', slug="index")
		p_fr.save()

		data['page'] = p_fr if data['language'] == 'FR' else p_en

	# load all pins without page
	data['pins'] = Pin.objects.filter(language=data['language'], page__slug="index" ).order_by("-id")

	# get news
	data['news'] = Pin.objects.filter(language=data['language'], page__isnull=True ).order_by("-id")

	return render_to_response( "%s/index.html" % data['template'], RequestContext(request, data ) )
Example #8
0
def legal( request ):
	data = shared_context( request, tags=[ "legal" ] )
	
	try:
		data['page'] = Page.objects.get( slug="legal-notice", language=data['language'])
	except Page.DoesNotExist:
		p_en = Page( title="Legal", language='EN', slug="legal-notice")
		p_en.save()

		p_fr = Page( title="Mentions légales", language='FR', slug="legal-notice")
		p_fr.save()

		data['page'] = p_fr if data['language'] == 'FR' else p_en

	# load all pins without page
	data['pins'] = Pin.objects.filter(language=data['language'], page__slug="legal-notice" ).order_by("-id")

	# get news
	# data['news'] = Pin.objects.filter(language=data['language'], page__isnull=True, status=Pin.published ).order_by("-id")

	return render_to_response(  "%s/legal.html" % data['template'], RequestContext(request, data ) )
Example #9
0
def index(request):
    data = shared_context(request, tags=["index"])

    try:
        data["page"] = Page.objects.get(slug="index", language=data["language"])
    except Page.DoesNotExist:
        p_en = Page(title="Home Page", language="EN", slug="index")
        p_en.save()

        p_fr = Page(title="Home Page", language="FR", slug="index")
        p_fr.save()

        data["page"] = p_fr if data["language"] == "FR" else p_en

        # load all pins without page
    data["pins"] = Pin.objects.filter(language=data["language"], page__slug="index").order_by("-id")

    # get news
    data["news"] = Pin.objects.filter(language=data["language"], page__isnull=True, status=Pin.published).order_by(
        "-id"
    )

    return render_to_response("%s/index.html" % data["template"], RequestContext(request, data))