~mhall119/ubuntu-api-website/content-editing

« back to all changes in this revision

Viewing changes to developer_network/web/views.py

  • Committer: mhall119
  • Date: 2013-09-23 21:27:54 UTC
  • Revision ID: mhall119@ubuntu.com-20130923212754-xgft32z15e2eekzx
Make subnav also depend on topic, add search page and functionality

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
    context = {
58
58
        'sidenav': topic_name,
 
59
        'topic': version.topic,
59
60
        'version': version,
60
61
        'first_column': first_column,
61
62
        'second_column': second_column,
70
71
    
71
72
    context = {
72
73
        'sidenav': topic_name,
 
74
        'topic': namespace.platform_section.topic_version.topic,
 
75
        'version': namespace.platform_section.topic_version,
73
76
        'namespace': namespace,
74
77
        'questions': questions,
75
78
        'tutorials': tutorials
89
92
    
90
93
    context = {
91
94
        'sidenav': topic_name,
 
95
        'topic': element.section.topic_version.topic,
 
96
        'version': element.section.topic_version,
92
97
        'element': element,
93
98
        'snippets': snippets,
94
99
        'questions': questions,
96
101
    }
97
102
    return render_to_response('web/element.html', context, RequestContext(request))
98
103
    
 
104
def search(request, topic_name, release_version):
 
105
    version = get_object_or_404(Version, topic__slug=topic_name, slug=release_version)
 
106
    query = request.GET.get('query', '')
 
107
    results = Element.objects.filter(section__topic_version=version, name__contains=query).order_by('section', 'fullname')
 
108
    
 
109
    context = {
 
110
        'sidenav': topic_name,
 
111
        'topic': version.topic,
 
112
        'version': version,
 
113
        'query': query,
 
114
        'results': results
 
115
    }
 
116
    return render_to_response('web/search.html', context, RequestContext(request))
 
117