예제 #1
0
파일: views.py 프로젝트: tvaught/conference
def wrap_page(request, **kwargs):
    """
    Wrap a static page in the template (headers, css, background, etc.)
    of a conference.

    """

    output = get_base_out_vars(request, **kwargs)

    output['page_id'] = kwargs.get('page', 'home')
    page_name = sub(r'(.*)-(.*)', r'\1 (\2)', output['page_id'].capitalize().replace('_', ' '))
    file_name = output['page_id'] + '.html'

    output['title'] = page_name

    output['page_path'] = output['conf_id'] + '/pages/' + file_name

    ## Decide which wrapper to use
    wrapper_template = DEFAULT_WRAPPER
    if output['page_id'] == 'home':
        wrapper_template = HOME_WRAPPER
    if output['page_id'] in NO_SIDE:
        wrapper_template = NOSIDE_WRAPPER

    try:
        template = loader.get_template(output['conf_style_id'] + wrapper_template).render(output)
    except TemplateDoesNotExist:
        output['page_path'] = output['conf_id'] + NOT_FOUND
        template = loader.get_template(output['conf_style_id'] + NOT_FOUND).render(output)

    response = HttpResponse(template)

    return response
예제 #2
0
def view_abstracts(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    abstracts = Presentation.objects.exclude(scheduleditem__itemType__name='Keynote')
    output['abstracts'] = abstracts.exclude(title="Waiting for confirmation.")
    output['levels'] = SponsorLevel.objects.filter(conference__exact=1)

    return render_to_response('sv2013/templates/speaking/abstracts.html', output)
예제 #3
0
def view_speakers(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    speakers = Speaker.objects.exclude(presentation__scheduleditem__itemType__name='Keynote')
    output['speakers'] = speakers.exclude(name="TBD")
    output['levels'] = SponsorLevel.objects.filter(conference__exact=1)

    return render_to_response('sv2013/templates/speaking/bios.html', output)
예제 #4
0
def view_keynotes(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    conference = kwargs['conference']
    keynotes = Speaker.objects.filter(presentation__scheduleditem__itemType__name='Keynote',presentation__conference__name=conference)
    output['keynotes'] = keynotes.order_by('-name')
    output['levels'] = SponsorLevel.objects.filter(conference__exact=CURRENT_CONF_ID)

    return render_to_response('%s/templates/speaking/keynotes.html' % conference, output)
예제 #5
0
def show_schedule_sectionDay(request, **kwargs):
    sectionDay = kwargs['sectionday']
    output = get_base_out_vars(request, **kwargs)
    output['debug'] = sectionDay
    output['sectionDay'] = SectionDay.objects.get(pk=sectionDay)
    output['tracks'] = set(Track.objects.filter(scheduleditem__timeSlot__sectionDay__exact=sectionDay))
    output['slots'] = TimeSlot.objects.filter(sectionDay__exact=sectionDay)
    return render_to_response('sv2013/templates/schedule/schedule.html', output)
예제 #6
0
def view_speakers(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    conference = kwargs['conference']
    speakers = Speaker.objects.exclude(presentation__scheduleditem__itemType__name='Keynote').distinct()
    speakers = speakers.filter(presentation__conference__name=conference)
    output['speakers'] = speakers.exclude(name="TBD")
    output['levels'] = SponsorLevel.objects.filter(conference__exact=CURRENT_CONF_ID)

    return render_to_response('%s/templates/speaking/bios.html' % conference, output)
예제 #7
0
파일: views.py 프로젝트: tvaught/conference
def view_proposal(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    proposal_id = kwargs.get('id', None)
    try:
        output['proposal'] = Proposal.objects.get(pk=proposal_id)
        template = 'sv2013/templates/speaking/propose_view.html'
    except ObjectDoesNotExist:
        output['proposals'] = Proposal.objects.all()
        template = 'sv2013/templates/speaking/propose_all.html'

    return render(request, template, output)
예제 #8
0
def view_news(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    conference = kwargs.get('conference')
    news = NewsItem.objects.filter(conference__name=conference).order_by('-date')
    if not request.user.is_staff:
        news = news.filter(publish=True)

    output['news'] = news
    output['levels'] = SponsorLevel.objects.filter(conference__name=conference)

    return render_to_response('%s/templates/news/news.html' % conference, output)
예제 #9
0
def wrap_page(request, **kwargs):
    """
    Wrap a static page in the template (headers, css, background, etc.)
    of a conference.

    """

    output = get_base_out_vars(request, **kwargs)

    output['page_id'] = kwargs.get('page', 'home')
    page_name = sub(r'(.*)-(.*)', r'\1 (\2)', output['page_id'].capitalize().replace('_', ' '))
    file_name = output['page_id'] + '.html'

    output['title'] = page_name

    output['page_path'] = output['conf_id'] + '/pages/' + file_name

    has_side = True
    ## Decide which wrapper to use
    wrapper_template = DEFAULT_WRAPPER
    if output['page_id'] == 'home':
        wrapper_template = HOME_WRAPPER
        from sponsors.models import Sponsor
        output['all_sponsors'] = Sponsor.objects.filter(level__conference=1)
        has_side = False
    if output['page_id'] in NO_SIDE:
        wrapper_template = NOSIDE_WRAPPER
        has_side = False

    if has_side:
        from sponsors.models import SponsorLevel
        output['levels'] = SponsorLevel.objects.filter(conference__exact=1)

    try:
        template = loader.get_template(output['conf_style_id'] + wrapper_template).render(output)
    except TemplateDoesNotExist:
        output['page_path'] = output['conf_id'] + NOT_FOUND
        template = loader.get_template(output['conf_style_id'] + NOT_FOUND).render(output)

    response = HttpResponse(template)

    return response
예제 #10
0
파일: views.py 프로젝트: tvaught/conference
def submit_proposal(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    if request.method == 'POST':
        form = ProposalForm(request.POST)
        if form.is_valid():
            new_proposal = form.save()
            process_speaker_proposal(new_proposal)
            output['proposal'] = new_proposal
            template = 'sv2013/templates/speaking/propose_view.html'
    else:
        proposal_id = kwargs.get('proposal', None)
        if proposal_id:
            proposal = Proposal.objects.get(pk=proposal_id)
            form = ProposalForm(instance=proposal)
        else:
            form = ProposalForm()
        template = 'sv2013/templates/speaking/propose.html'

    output['form'] = form

    return render(request, template, output)
예제 #11
0
def common(request, **kwargs):
    """
    PyData Common Content
    """

    site                = 'base'
    NO_SIDE             = ['sponsors', ]

    output = get_base_out_vars(request, conference=site, **kwargs)

    output['page_id']   = kwargs.get('page', 'home')
    file_name           = output['page_id'] + '.html'
    output['title']     = sub(r'(.*)-(.*)', r'\1 (\2)', output['page_id'].capitalize().replace('_', ' '))
    output['page_path'] = '%s/pages/' % site + file_name

    NOT_FOUND           = '%s/templates/not_found.html'         % site
    DEFAULT_WRAPPER     = '%s/templates/wrapper.html'           % site
    HOME_WRAPPER        = '%s/templates/home_wrapper.html'      % site
    NOSIDE_WRAPPER      = '%s/templates/noside_wrapper.html'    % site
    EDIT_WRAPPER        = '%s/templates/edit_page.html'         % site

    
    has_side = True
    ## Decide which wrapper to use
    wrapper_template = DEFAULT_WRAPPER
    if output['page_id'] == 'home':
        wrapper_template = HOME_WRAPPER
        output['all_sponsors'] = []
        levels = SponsorLevel.objects.filter(conference__name=site)
        for level in levels:
            output['all_sponsors'].extend(level.sponsors.all())
        conference = kwargs.get('conference')
        news = NewsItem.objects.filter(conference__name=conference).order_by('-date')
        if not request.user.is_staff:
            news = news.filter(publish=True)
        output['news'] = news.filter(date__lte=datetime.now())[:5]
        has_side = False

    if output['page_id'] in NO_SIDE:
        wrapper_template = NOSIDE_WRAPPER
        has_side = False

    if has_side:
        pass # nothing to do now

    editable = request.GET.get('edit', 0)

    if request.method == 'POST':
        editable = 0
        page_contents = request.POST['page_contents']
        set_file_contents(output['page_path'], page_contents)

    if editable == '1' and request.user.is_staff:
        output['page_contents'] = get_file_contents(output['page_path'])
        output['repost_link'] = request.path_info
        template = loader.get_template(EDIT_WRAPPER).render(output)
    else:
        template = loader.get_template(wrapper_template).render(output)

    response = HttpResponse(template)

    return response
예제 #12
0
def wrap_page(request, **kwargs):
    """
    Wrap a static page in the template (headers, css, background, etc.)
    of a conference.

    """

    output = get_base_out_vars(request, **kwargs)

    output['page_id'] = kwargs.get('page', 'home')
    page_name = sub(r'(.*)-(.*)', r'\1 (\2)', output['page_id'].capitalize().replace('_', ' '))
    file_name = output['page_id'] + '.html'

    output['title'] = page_name


    conference      = output['conference']
    NOT_FOUND       = '%s/templates/not_found.html'         % conference
    DEFAULT_WRAPPER = '%s/templates/wrapper.html'           % conference
    HOME_WRAPPER    = '%s/templates/home_wrapper.html'      % conference
    NOSIDE_WRAPPER  = '%s/templates/noside_wrapper.html'    % conference
    EDIT_WRAPPER    = '%s/templates/edit_page.html'         % conference

    NO_SIDE = ['venue', 'sponsor/sponsors', ]

    if (kwargs.get('about',None)):
        output['page_path'] =  '%s/pages/about/' % conference + file_name
    else:
        output['page_path'] = '%s/pages/' % conference + file_name
    

    has_side = True
    ## Decide which wrapper to use
    wrapper_template = DEFAULT_WRAPPER
    if output['page_id'] == 'home':
        wrapper_template = HOME_WRAPPER
        output['all_sponsors'] = []
        levels = SponsorLevel.objects.filter(conference__name=conference)
        for level in levels:
            output['all_sponsors'].extend(level.sponsors.all())
        conference = kwargs.get('conference')
        news = NewsItem.objects.filter(conference__name=conference).order_by('-date')
        if not request.user.is_staff:
            news = news.filter(publish=True)
        output['news'] = news.filter(date__lte=datetime.now())[:5]
        has_side = False
    if output['page_id'] in NO_SIDE:
        wrapper_template = NOSIDE_WRAPPER
        has_side = False

    if has_side:
        output['levels'] = SponsorLevel.objects.filter(conference__name=conference)

    editable = request.GET.get('edit', 0)

    if request.method == 'POST':
        editable = 0
        page_contents = request.POST['page_contents']
        set_file_contents(output['page_path'], page_contents)

    if editable == '1' and request.user.is_staff:
        output['page_contents'] = get_file_contents(output['page_path'])
        output['repost_link'] = request.path_info
        template = loader.get_template(EDIT_WRAPPER).render(output)
    else:
        #try:
        template = loader.get_template(wrapper_template).render(output)
        #except TemplateDoesNotExist:
        #    template = loader.get_template(NOT_FOUND).render(output)

    response = HttpResponse(template)

    return response
예제 #13
0
def show_all_sponsors(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    levels = SponsorLevel.objects.filter(conference__exact=1)
    output['levels'] = levels
    return render_to_response('sv2013/templates/sponsors/sponsor_list.html', output)
예제 #14
0
파일: views.py 프로젝트: tvaught/conference
def view_all(request):
    output = get_base_out_vars(request)
    output['proposals'] = Proposal.objects.all()

    return render(request, 'sv2013/templates/speaking/propose_all.html', output)
예제 #15
0
def show_all_sponsors(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    conference = kwargs['conference']
    levels = SponsorLevel.objects.filter(conference__name=conference)
    output['levels'] = levels
    return render_to_response('%s/templates/sponsors/sponsor_list.html' % conference, output)
예제 #16
0
def show_schedule_all(request, **kwargs):
    output = get_base_out_vars(request, **kwargs)
    output['sections'] = Section.objects.all()
    return render_to_response('sv2013/templates/schedule/full_schedule.html', output)