django.template.context.RequestContext

Here are the examples of the python api django.template.context.RequestContext taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

Project: talk.org
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=AUTO_ID)
        return render_to_response(self.form_template,
            {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
            context_instance=RequestContext(request))

Example 2

Project: talk.org
Source File: preview.py
View license
    def preview_post(self, request):
        "Validates the POST data. If valid, displays the preview page. Else, redisplays form."
        f = self.form(request.POST, auto_id=AUTO_ID)
        context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}
        if f.is_valid():
            context['hash_field'] = self.unused_name('hash')
            context['hash_value'] = self.security_hash(request, f)
            return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
        else:
            return render_to_response(self.form_template, context, context_instance=RequestContext(request))

Example 3

Project: talk.org
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=AUTO_ID)
        if f.is_valid():
            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
                context_instance=RequestContext(request))

Example 4

Project: GAE-Bulk-Mailer
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=self.get_auto_id(), initial=self.get_initial(request))
        return render_to_response(self.form_template,
            self.get_context(request, f),
            context_instance=RequestContext(request))

Example 5

Project: PyClassLessons
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=self.get_auto_id(), initial=self.get_initial(request))
        return render_to_response(self.form_template,
            self.get_context(request, f),
            context_instance=RequestContext(request))

Example 6

Project: PyClassLessons
Source File: preview.py
View license
    def preview_post(self, request):
        "Validates the POST data. If valid, displays the preview page. Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        context = self.get_context(request, f)
        if f.is_valid():
            self.process_preview(request, f, context)
            context['hash_field'] = self.unused_name('hash')
            context['hash_value'] = self.security_hash(request, f)
            return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
        else:
            return render_to_response(self.form_template, context, context_instance=RequestContext(request))

Example 7

Project: pythondigest
Source File: views.py
View license
def conflict(request, target=None, template_name='409.html'):
    template = loader.get_template(template_name)
    message = 'Вот незадача! Кажется эту новость обновили раньше =( \
            Нужно обновить новость для того чтобы внести правки.'

    ctx = RequestContext(request, {'message': message})
    return ConflictResponse(template.render(ctx))

Example 8

View license
    def render_tag(self, context, form_key):
        form_key = form_key if form_key else DEFAULT_FORM_KEY
        form = get_feedback_form(form_key)()
        if PREFIX_KEY_FIELDS:
            form.prefix = form_key

        return render_to_string([
            'feedback/%s/feedback.html' % form_key,
            'feedback/feedback.html',
            ], {'form':form}, context_instance=RequestContext(context['request']))

Example 9

Project: ReviewBot
Source File: admin.py
View license
    def refresh_tools_view(self, request, template_name='refresh.html'):
        Tool.objects.all().update(in_last_update=False)
        ReviewBotExtension.instance.send_refresh_tools()

        return render_to_response(
            template_name,
            RequestContext(request, {},  current_app=self.admin_site.name))

Example 10

Project: oioioi
Source File: controllers.py
View license
    def _render_disqualification_reason(self, request, submission):
        """Renders part with reason of the given submission disqualification.

           This method is only used internally.
        """
        reasons = Disqualification.objects.filter(submission=submission)
        if not is_contest_admin(request):
            reasons = reasons.filter(guilty=True)

        if not reasons:
            return mark_safe("")
        return render_to_string('disqualification/custom.html',
            context_instance=RequestContext(request, {
                'submission': submission_template_context(request,
                    submission.programsubmission),
                'reasons': reasons,
            }))

Example 11

Project: oioioi
Source File: controllers.py
View license
    def render_submission_disqualifiaction(self, request, submission):
        """Renders the disqualification reason of the given submission to HTML.
        """
        reason = self._render_disqualification_reason(request, submission)
        template = 'disqualification/generic.html'

        if is_contest_admin(request):
            template = 'disqualification/generic_admin.html'

        return render_to_string(template,
            context_instance=RequestContext(request, {
                'submission': submission_template_context(request,
                    submission.programsubmission),
                'reason': reason,
            }))

Example 12

Project: splunk-webframework
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        if f.is_valid():
            if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),
                                             request, f):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                self.get_context(request, f),
                context_instance=RequestContext(request))

Example 13

Project: stream_framework_example
Source File: views.py
View license
def trending(request):
    '''
    The most popular items
    '''
    if not request.user.is_authenticated():
        # hack to log you in automatically for the demo app
        admin_user = authenticate(username='admin', password='admin')
        auth_login(request, admin_user)

    # show a few items
    context = RequestContext(request)
    popular = Item.objects.all()[:50]
    context['popular'] = popular
    response = render_to_response('core/trending.html', context)
    return response

Example 14

Project: stream_framework_example
Source File: views.py
View license
@login_required
def aggregated_feed(request):
    '''
    Items pinned by the people you follow
    '''
    context = RequestContext(request)
    feed = manager.get_feeds(request.user.id)['aggregated']
    if request.REQUEST.get('delete'):
        feed.delete()
    activities = list(feed[:25])
    if request.REQUEST.get('raise'):
        raise Exception, activities
    context['feed_pins'] = enrich_aggregated_activities(activities)
    response = render_to_response('core/aggregated_feed.html', context)
    return response

Example 15

Project: stream_framework_example
Source File: views.py
View license
def profile(request, username):
    '''
    Shows the users profile
    '''
    profile_user = get_user_model().objects.get(username=username)
    feed = manager.get_user_feed(profile_user.id)
    if request.REQUEST.get('delete'):
        feed.delete()
    activities = list(feed[:25])
    context = RequestContext(request)
    context['profile_user'] = profile_user
    context['profile_pins'] = enrich_activities(activities)
    response = render_to_response('core/profile.html', context)
    return response

Example 16

Project: tendenci
Source File: views.py
View license
@is_enabled('help_files')
def index(request, template_name="help_files/index.html"):
    """List all topics and all links"""
    topic_pks = []
    filters = get_query_filters(request.user, 'help_files.view_helpfile')
    
    topics = Topic.objects.filter(id__in=HelpFile.objects.values_list('topics')).order_by('title')
    m = len(topics) / 2
    topics = topics[:m], topics[m:] # two columns
    most_viewed = HelpFile.objects.filter(filters).order_by('-view_totals').distinct()[:5]
    featured = HelpFile.objects.filter(filters).filter(is_featured=True).distinct()[:5]
    faq = HelpFile.objects.filter(filters).filter(is_faq=True).distinct()[:3]

    EventLog.objects.log()

    return render_to_response(template_name, locals(),
        context_instance=RequestContext(request))

Example 17

Project: tendenci
Source File: views.py
View license
def detail(request, slug, template_name="videos/details.html"):
    "Video page with embed code printed"

    categories = Category.objects.all()

    video = get_object_or_404(Video, slug=slug)

    if has_perm(request.user, 'videos.view_video', video):
        EventLog.objects.log(instance=video)

        return render_to_response(template_name, {'video': video,'categories': categories},
            context_instance=RequestContext(request))
    else:
        raise Http403

Example 18

Project: ProjectNarwhal
Source File: views.py
View license
    def form_valid(self, form):
        invite = Invite(inviter = self.request.user, email_address = form.cleaned_data['email_address'])
        message = EmailMessage(subject=_('You have been invited to join %(site_name)s by %(user).') %\
                                            {'site_name': settings.SITE_NAME, 'user': invite.invitee.username },
                               body = loader.get_template("invite_email.html").render(RequestContext({'invite':invite})),
                               to = invite.email_address)
        
        try:
            message.send()
            invite.save()
            return HttpResponseRedirect(self.success_url)
        
        except: 
            form.errors += ErrorList(['Could not send email to that address.'])
            return self.form_invalid(form)

Example 19

Project: dynamic-models
Source File: views.py
View license
def all_survey_responses(request):
    template_name = "surveymaker/all.html"

    surveys = [(survey, survey.Response.objects.all()) 
                                    for survey in Survey.objects.all()]
    return render_to_response(template_name, {'surveys': surveys}, 
                                context_instance=RequestContext(request))

Example 20

Project: dynamic-models
Source File: views.py
View license
def survey_form(request, survey_slug):
    template_name = "surveymaker/survey_form.html"
    survey = get_object_or_404(Survey, slug=survey_slug)
    Response = survey.Response
    ResponseForm = get_response_form(Response)

    if request.method == "POST":
        form = ResponseForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('surveymaker_index')
    else:
        form = ResponseForm()

    return render_to_response(template_name, {'form': form, 'survey': survey}, 
                                context_instance=RequestContext(request))

Example 21

View license
    def setUp(self):
        # create context mock
        request = RequestFactory().get('/')
        request.user = AnonymousUser()
        SessionMiddleware().process_request(request)
        request.session.save()
        self.context = RequestContext(request)
        self.plugin = mixer.blend('image_gallery.GalleryPlugin')
        self.cmsplugin = CMSGalleryPlugin()

Example 22

View license
    def setUp(self):
        # create context mock
        request = RequestFactory().get('/')
        request.user = AnonymousUser()
        SessionMiddleware().process_request(request)
        request.session.save()
        self.context = RequestContext(request)
        self.gallery = mixer.blend('image_gallery.Gallery', is_published=True,
                                   folder=mixer.blend('filer.Folder'))

Example 23

Project: django-object-events
Source File: tags_tests.py
View license
    def test_tag(self):
        # create context mock
        request = RequestFactory().get('/')
        request.user = AnonymousUser()
        SessionMiddleware().process_request(request)
        request.session.save()
        context = RequestContext(request)

        # Returns empty dict if there is no authenticated user
        self.assertEqual(render_notifications(context), '\n')

        # Returns notifications.html
        request.user = UserFactory()
        ObjectEventFactory(user=request.user)
        self.assertTrue(render_notifications(context))

Example 24

Project: django-crumbs
Source File: tests.py
View license
    def test_add_kwargs(self):
        template = Template("{% load breadcrumb_tags %}{% add_crumb crumb='Home' url='/home/' %}")
        request = RequestFactory().get('/')
        context = RequestContext(request)
        result = template.render(context)
        self.assertEqual(result, '')
        self.assertEqual(request.breadcrumbs, [('Home', '/home/')])

Example 25

Project: django-crumbs
Source File: tests.py
View license
    def test_add_with_args(self):
        template = Template("{% load breadcrumb_tags %}{% add_crumb 'Details' 'detail_view' 44 %}")
        request = RequestFactory().get('/')
        context = RequestContext(request)
        result = template.render(context)
        self.assertEqual(result, '')
        self.assertEqual(request.breadcrumbs, [('Details', '/detail_view/44/')])

Example 26

View license
    def render_template_tag(self, slug, context=None, default='<p>Default.</p>', url=None):
        "Render the template tag."
        context = context or {}
        if not url:
            tag = '{{% load scribbler_tags %}}{{% scribble {0} %}}{1}{{% endscribble %}}'
        else:
            tag = '{{% load scribbler_tags %}}{{% scribble {0} {2} %}}{1}{{% endscribble %}}'
        template = Template(tag.format(slug, default, url))
        context = RequestContext(self.request, context)
        return template.render(context)

Example 27

View license
    def render_template_tag(self, model_instance, field_name, context=None):
        "Render the template tag."
        context = context or {}
        context['model_instance'] = model_instance
        template = Template("""
            {{% load scribbler_tags %}}{{% scribble_field model_instance '{0}' %}}
        """.format(field_name))
        context = RequestContext(self.request, context)
        return template.render(context)

Example 28

Project: django-nonrel
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=self.get_auto_id(), initial=self.get_initial(request))
        return render_to_response(self.form_template,
            self.get_context(request, f),
            context_instance=RequestContext(request))

Example 29

Project: django-nonrel
Source File: preview.py
View license
    def preview_post(self, request):
        "Validates the POST data. If valid, displays the preview page. Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        context = self.get_context(request, f)
        if f.is_valid():
            self.process_preview(request, f, context)
            context['hash_field'] = self.unused_name('hash')
            context['hash_value'] = self.security_hash(request, f)
            return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
        else:
            return render_to_response(self.form_template, context, context_instance=RequestContext(request))

Example 30

Project: django-nonrel
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        if f.is_valid():
            if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),
                                             request, f):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                self.get_context(request, f),
                context_instance=RequestContext(request))

Example 31

Project: django-breadcrumbs
Source File: views.py
View license
def someview(request):
    request.breadcrumbs('just a view to show some url', request.path)

    return render_to_response('home.html',
        {'text': 'Hello, this is some second view'},
        context_instance=RequestContext(request))

Example 32

Project: django-breadcrumbs
Source File: views.py
View license
def someview(request):
    request.breadcrumbs('just a view to show some url', request.path)

    return render_to_response('home.html',
        {'text': 'Hello, this is some second view'},
        context_instance=RequestContext(request))

Example 33

Project: hue
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=self.get_auto_id(), initial=self.get_initial(request))
        return render_to_response(self.form_template,
            self.get_context(request, f),
            context_instance=RequestContext(request))

Example 34

Project: hue
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        if f.is_valid():
            if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),
                                             request, f):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                self.get_context(request, f),
                context_instance=RequestContext(request))

Example 35

Project: decode-Django
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=self.get_auto_id(), initial=self.get_initial(request))
        return render_to_response(self.form_template,
            self.get_context(request, f),
            context_instance=RequestContext(request))

Example 36

Project: decode-Django
Source File: preview.py
View license
    def preview_post(self, request):
        "Validates the POST data. If valid, displays the preview page. Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        context = self.get_context(request, f)
        if f.is_valid():
            self.process_preview(request, f, context)
            context['hash_field'] = self.unused_name('hash')
            context['hash_value'] = self.security_hash(request, f)
            return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
        else:
            return render_to_response(self.form_template, context, context_instance=RequestContext(request))

Example 37

Project: decode-Django
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        if f.is_valid():
            if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),
                                             request, f):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                self.get_context(request, f),
                context_instance=RequestContext(request))

Example 38

Project: django-compositepks
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=AUTO_ID)
        return render_to_response(self.form_template,
            {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
            context_instance=RequestContext(request))

Example 39

Project: django-fluent-contents
Source File: views.py
View license
def page_detail(request, path):
    stripped = path.strip('/') if path else ''
    stripped = stripped and u'/%s/' % stripped or '/'

    try:
        page = Page.objects.get(_cached_url=stripped)
    except Page.DoesNotExist:
        raise Http404("No page found for the path '%s'" % stripped)

    return render_to_response(page.template_name, {
        'simplecms_page': page,
    }, context_instance=RequestContext(request))

Example 40

Project: ella
Source File: newman_admin.py
View license
    def mass_upload_view(self, request):
        context = self.get_mass_upload_context(request)
        return render_to_response('newman/photos/photo/mass_upload.html',
            context, context_instance=RequestContext(request,
                                                     current_app=self.admin_site.name)
        )

Example 41

Project: django-kong
Source File: views.py
View license
def test_detail_for_site(request, site_slug, test_slug):
    test = Test.objects.get(slug=test_slug)
    site = Site.objects.get(slug=site_slug)
    result = TestResult.objects.filter(test=test, site=site)[0]
    flot_list = flotify(result)
    return render_to_response('kong/test_list_for_site.html',
                       {'result': result,
                        'flot_list': flot_list
                        },
                       context_instance=RequestContext(request))

Example 42

Project: django-kong
Source File: views.py
View license
def graph_test(request, test_slug, num_total=5000, div_by=50):
    test = Test.objects.get(slug=test_slug)
    sites = test.all_sites.all()
    flot_val = graphify(sites, test, num_total, div_by)
    return render_to_response('kong/graph_test.html',
                              {'sites': list(sites),
                               'flot_list': flot_val.items(),
                                'test': test,
                              },
                              context_instance=RequestContext(request))

Example 43

Project: django-kong
Source File: views.py
View license
def dashboard(request):
    ret_val = {}
    for site in Site.objects.all():
        results = site.latest_results()
        succ = True
        for result in results:
            if not result.succeeded:
                succ = False
                fail = result
        ret_val[site.slug] = succ
    return render_to_response('kong/dashboard.html',
                       {'results': ret_val},
                       context_instance=RequestContext(request))

Example 44

Project: lettuce
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=AUTO_ID)
        if f.is_valid():
            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
                context_instance=RequestContext(request))

Example 45

Project: Geotrek-admin
Source File: views.py
View license
@login_required
@user_passes_test(lambda u: u.is_superuser)
def sync_view(request):
    """
    Custom views to view / track / launch a sync rando
    """

    return render_to_response(
        'trekking/sync_rando.html',
        {'form': SyncRandoForm(), },
        context_instance=RequestContext(request)
    )

Example 46

Project: django_twitter
Source File: views.py
View license
    def get(self, request):
        if not request.user.is_authenticated() and not settings.USE_AUTH:
            admin_user = authenticate(
                username=settings.DEMO_USERNAME, password=settings.DEMO_PASSWORD)
            auth_login(request, admin_user)
        context = RequestContext(request)
        context_dict = {
            'greeting': self.greeting,
            'login_user': request.user,
            'users': User.objects.order_by('date_joined')[:50]
        }
        return render_to_response('stream_twitter/home.html', context_dict, context)

Example 47

Project: feedsanitizer
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=self.get_auto_id())
        if f.is_valid():
            if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),
                                             request, f):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                self.get_context(request, f),
                context_instance=RequestContext(request))

Example 48

Project: hortonworks-sandbox
Source File: preview.py
View license
    def preview_get(self, request):
        "Displays the form"
        f = self.form(auto_id=AUTO_ID)
        return render_to_response(self.form_template,
            {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
            context_instance=RequestContext(request))

Example 49

Project: hortonworks-sandbox
Source File: preview.py
View license
    def post_post(self, request):
        "Validates the POST data. If valid, calls done(). Else, redisplays form."
        f = self.form(request.POST, auto_id=AUTO_ID)
        if f.is_valid():
            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
                return self.failed_hash(request) # Security hash failed.
            return self.done(request, f.cleaned_data)
        else:
            return render_to_response(self.form_template,
                {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
                context_instance=RequestContext(request))

Example 50

Project: hunch-gift-app
Source File: preview.py
View license
    def preview_post(self, request):
        "Validates the POST data. If valid, displays the preview page. Else, redisplays form."
        f = self.form(request.POST, auto_id=AUTO_ID)
        context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}
        if f.is_valid():
            self.process_preview(request, f, context) 
            context['hash_field'] = self.unused_name('hash')
            context['hash_value'] = self.security_hash(request, f)
            return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
        else:
            return render_to_response(self.form_template, context, context_instance=RequestContext(request))