SushantGautam commited on
Commit
0f380ab
·
1 Parent(s): 3f469ac

Enhance topic detail view by prefetching author yearly stats and update footer styling for improved layout

Browse files
core/templates/base.html CHANGED
@@ -59,7 +59,7 @@
59
  </main>
60
 
61
  <!-- Footer -->
62
- <footer class="bg-dark text-white text-center py-1 mt-auto">
63
  <div class="container">
64
  <p>&copy; 2025 BridgeMentor. All rights reserved. v0.001, α-testing </p>
65
  <div style="border: 1px solid #ccc; margin-bottom: 20px; text-align: center;">
 
59
  </main>
60
 
61
  <!-- Footer -->
62
+ <footer class="bg-dark text-white text-center mt-2 pt-2">
63
  <div class="container">
64
  <p>&copy; 2025 BridgeMentor. All rights reserved. v0.001, α-testing </p>
65
  <div style="border: 1px solid #ccc; margin-bottom: 20px; text-align: center;">
core/templates/topic/detail.html CHANGED
@@ -1,11 +1,70 @@
1
  {% extends "base.html" %}
2
  {% block title %}{{ item.name }}{% endblock %}
 
 
 
3
  {% block content %}
4
  <h2>{{ item.name }}</h2>
5
  <h3>Researchers in this Topic:</h3>
6
- <ul>
7
- {% for author_topic in authors %}
8
- <li><a href="{% url 'author_detail' author_topic.author.id %}">{{ author_topic.author.name }}</a></li>
9
- {% endfor %}
10
- </ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  {% endblock %}
 
1
  {% extends "base.html" %}
2
  {% block title %}{{ item.name }}{% endblock %}
3
+ {% block css %}
4
+ <link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/jquery.dataTables.min.css">
5
+ {% endblock %}
6
  {% block content %}
7
  <h2>{{ item.name }}</h2>
8
  <h3>Researchers in this Topic:</h3>
9
+ <table id="authors-table" class="display responsive nowrap" style="width:100%">
10
+ <thead>
11
+ <tr>
12
+ <th>Name</th>
13
+ <th>Affiliation</th>
14
+ <th>i10</th>
15
+ <th>Cited</th>
16
+ <th>Works</th>
17
+ <th>Mean 2-Year Citedness</th>
18
+ <th>Active</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ {% for author_topic in authors %}
23
+ <tr>
24
+ <td>
25
+ <a href="{% url 'author_detail' author_topic.author.id %}">
26
+ {{ author_topic.author.name }}
27
+ </a>
28
+ </td>
29
+ <td>
30
+ {% with author_topic.author.latest_affiliation as affiliation %}
31
+ {% if affiliation %}
32
+ {{ affiliation.institution.name }}
33
+ {% else %}
34
+ Latest affiliation
35
+ {% endif %}
36
+ {% endwith %}
37
+ </td>
38
+ <td>{{ author_topic.author.i10_index }}</td>
39
+ <td>{{ author_topic.author.cited_by_count }}</td>
40
+ <td>{{ author_topic.author.works_count }}</td>
41
+ <td>{{ author_topic.author.mean_2yr_citedness|floatformat:2 }}</td>
42
+ <td>
43
+ {% with author_topic.author.yearly_stats.last as last_stat %}
44
+ {% if last_stat %}
45
+ {{ last_stat.year }}
46
+ {% else %}
47
+ N/A
48
+ {% endif %}
49
+ {% endwith %}
50
+ </td>
51
+ </tr>
52
+ {% endfor %}
53
+ </tbody>
54
+ </table>
55
+ {% endblock %}
56
+ {% block js %}
57
+ <script src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
58
+ <script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>
59
+ <script>
60
+ document.addEventListener("DOMContentLoaded", function () {
61
+ $('#authors-table').DataTable({
62
+ responsive: true, // Ensures responsiveness
63
+ search: true,
64
+ paging: true,
65
+ ordering: true,
66
+ info: true,
67
+ });
68
+ });
69
+ </script>
70
  {% endblock %}
core/views.py CHANGED
@@ -160,7 +160,8 @@ def topic_list(request):
160
 
161
  def topic_detail(request, pk):
162
  topic = get_object_or_404(Topic, id=pk)
163
- authors = AuthorTopic.objects.filter(topic=topic).select_related('author')
 
164
  return render(request, 'topic/detail.html', {'item': topic, 'authors': authors})
165
 
166
  # Author views
 
160
 
161
  def topic_detail(request, pk):
162
  topic = get_object_or_404(Topic, id=pk)
163
+ authors = AuthorTopic.objects.filter(topic=topic).select_related(
164
+ 'author').prefetch_related('author__yearly_stats')
165
  return render(request, 'topic/detail.html', {'item': topic, 'authors': authors})
166
 
167
  # Author views