Пример #1
0
def senator(request, representative_id=None):
    """senator page"""
    to_response = {}
    to_response['senator'] = get_object_or_404(Representative.objects.select_related(), pk=representative_id)
    try:
        bookmark = Bookmark.objects.get(
            user=request.user, 
            content_type=ContentType.objects.get_for_model(Representative),
            object_id=to_response['senator'].id,
        )
        to_response['bookmark'] = bookmark
    except Exception, e:
        bookmark = Bookmark()
        bookmark.content_object = to_response['senator']
Пример #2
0
def bill(request, bill_id=None):
    """bill page"""
    to_response = {}
    to_response['bill'] = get_object_or_404(Bill.objects.select_related(), pk=bill_id)
    try:
        bookmark = Bookmark.objects.get(
            user=request.user, 
            content_type=ContentType.objects.get_for_model(Bill),
            object_id=to_response['bill'].id,
        )
        to_response['bookmark'] = bookmark
    except Exception, e:
        bookmark = Bookmark()
        bookmark.content_object = to_response['bill']
Пример #3
0
 def extra_context(self, *args, **kwargs):
     """return the context for the search view"""
     context = super(TWFASearchView, self).extra_context(*args, **kwargs)
     saved_search, created = SavedSearch.objects.get_or_create(
                             hashed_search=SavedSearch.create_hash(self.query),
                             search=self.query,
                             )
     try:
         bookmark = Bookmark.objects.get(
             user=self.request.user,
             content_type=ContentType.objects.get_for_model(SavedSearch),
             object_id=saved_search.id,
         )
         context['bookmark'] = bookmark
     except Exception, e:
         bookmark = Bookmark()
         bookmark.content_object = saved_search
Пример #4
0
        if district.area.boundary.distance(slocation) < 0.01:
            totemplate['boundary_close'] = True
    else:
        gmap = district.gmap()
    totemplate['gmap'] = gmap

    try:
        bookmark = Bookmark.objects.get(
            user=request.user,
            content_type=ContentType.objects.get_for_model(District),
            object_id=totemplate['district'].id,
        )
        totemplate['bookmark'] = bookmark
    except Exception, e:
        bookmark = Bookmark()
        bookmark.content_object = totemplate['district']
    totemplate['bookmarkform'] = BookmarkForm(instance=bookmark)

    return render_to_response('district.html', totemplate, context_instance=RequestContext(request))

def senator(request, representative_id=None):
    """senator page"""
    to_response = {}
    to_response['senator'] = get_object_or_404(Representative.objects.select_related(), pk=representative_id)
    try:
        bookmark = Bookmark.objects.get(
            user=request.user, 
            content_type=ContentType.objects.get_for_model(Representative),
            object_id=to_response['senator'].id,
        )
        to_response['bookmark'] = bookmark