Permalink
Browse files

Convert get_url()s to get_absolute_url()

  • Loading branch information...
1 parent 2864c16 commit a09404806d8e2c28d39cf0bf7524865d72590269 @dellsystem committed Dec 17, 2011
View
@@ -13,8 +13,9 @@ class BlogPost(models.Model):
def __unicode__(self):
return "%s (%s)" % (self.title, self.timestamp.strftime("%B %d, %Y"))
- def get_url(self):
- return "/news/%s" % self.slug
+ @models.permalink
+ def get_absolute_url(self):
+ return ('news_view', (), {'slug': self.slug})
def get_num_comments(self):
return self.blogcomment_set.count()
View
@@ -88,7 +88,7 @@
{% else %}
<div style="float: right;"><p><a href="/ucp" class="btn info" style="font-weight: normal;">User control panel</a>{% if user.is_staff %} <a href="/admin" class="btn" style="font-weight: normal; color: #000;">Admin</a>{% endif %}</p><p><input type="submit" class="btn danger" value="Log out ({{ user }})" name="logout" /></p></div>
{% load gravatar %}
- <div style="float: left; margin-right: 10px;"><a href="{{ user.get_profile.get_url }}"><img src="{% gravatar_for_user user 70 %}" alt="Your Gravatar" /></a></div>
+ <div style="float: left; margin-right: 10px;"><a href="{{ user.get_profile.get_absolute_url }}"><img src="{% gravatar_for_user user 70 %}" alt="Your Gravatar" /></a></div>
{% endif %}
</form>
</div>
@@ -22,9 +22,9 @@
<tbody>
{% for course in courses %}
<tr>
- <td><a href="{{ course.get_url }}">{{ course }}</a></td>
- <td><a href="{{ course.department.get_url }}">{{ course.department.long_name }}</ta></td>
- <td><a href="{{ course.department.faculty.get_url }}">{{ course.department.faculty }}</a></td>
+ <td><a href="{{ course.get_absolute_url }}">{{ course }}</a></td>
+ <td><a href="{{ course.department.get_absolute_url }}">{{ course.department.long_name }}</ta></td>
+ <td><a href="{{ course.department.faculty.get_absolute_url }}">{{ course.department.faculty }}</a></td>
<td>None</td>
<td>{{ course.num_watchers }}</td>
<td>{{ course.latest_activity.timestamp|date:"F j Y f" }}</td>
@@ -14,7 +14,7 @@
{% if dept.courses %}
<ul class="unstyled">
{% for course in dept.courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -12,15 +12,15 @@
<img src="{{ dept.get_image }}" title="{{ dept.long_name }}" />
</div>
<div class="span14 justify-align">
- <p><a href="{{ dept.faculty.get_url }}">{{ dept.faculty }}</a></p>
+ <p><a href="{{ dept.faculty.get_absolute_url }}">{{ dept.faculty }}</a></p>
<p><strong>{{ num_pages }}</strong> pages in <strong>{{ courses.count }}</strong> courses</p>
</div>
</div>
<h2>Courses</h2>
{% if courses %}
<ul>
{% for course in courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% endif %}
@@ -14,7 +14,7 @@
{% if faculty.courses %}
<ul class="unstyled">
{% for course in faculty.courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -18,8 +18,8 @@
<div class="row">
{% for dept in departments %}
<div class="span2 center-align icon-thumb">
- <a href="{{ dept.get_url }}"><img src="{{ dept.get_image }}" title="Department of {{ dept.long_name }} ({{ dept.short_name }})" /></a>
- <p><a href="{{ dept.get_url }}">{{ dept.short_name }}</a></p>
+ <a href="{{ dept.get_absolute_url }}"><img src="{{ dept.get_image }}" title="Department of {{ dept.long_name }} ({{ dept.short_name }})" /></a>
+ <p><a href="{{ dept.get_absolute_url }}">{{ dept.short_name }}</a></p>
</div>
{% if forloop.counter|divisibleby:8 %}
</div>
@@ -33,8 +33,8 @@
<div class="row">
{% for course in courses %}
<div class="span2 center-align icon-thumb">
- <a href="{{ course.get_url }}"><img src="{{ course.department.get_image }}" title="{{ course }} ({{ course.name }})" /></a>
- <p><a href="{{ course.get_url }}">{{ course }}</a></p>
+ <a href="{{ course.get_absolute_url }}"><img src="{{ course.department.get_image }}" title="{{ course }} ({{ course.name }})" /></a>
+ <p><a href="{{ course.get_absolute_url }}">{{ course }}</a></p>
</div>
{% if forloop.counter|divisibleby:8 %}
</div>
@@ -18,17 +18,17 @@
<h2>Top 10 popular courses</h2>
<p>To view all the courses in our catalogue, sorted by popularity (i.e. the number of watchers), <a href="/courses/popular">click here</a>. NOTE: should go to the same page as courses/all but sorted by popularity.</p>
{% for course in popular_courses %}
- <p style="display: inline-block; padding: 5px; text-align: center;" class="icon-thumb"><a href="{{ course.get_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course }}" /></a><br /><a href="{{ course.get_url }}">{{ course }}</a></p>
+ <p style="display: inline-block; padding: 5px; text-align: center;" class="icon-thumb"><a href="{{ course.get_absolute_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course }}" /></a><br /><a href="{{ course.get_absolute_url }}">{{ course }}</a></p>
{% endfor %}
<h2>Top 10 active courses</h2>
<p>To view all the courses in our catalogue, sorted by activity (i.e. the time at which the last page edit or whatever was made), <a href="/courses/active">click here</a>.</p>
{% for course in active_courses %}
- <p style="display: inline-block; padding: 5px; text-align: center;" class="icon-thumb"><a href="{{ course.get_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course }}" /></a><br /><a href="{{ course.get_url }}">{{ course }}</a></p>
+ <p style="display: inline-block; padding: 5px; text-align: center;" class="icon-thumb"><a href="{{ course.get_absolute_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course }}" /></a><br /><a href="{{ course.get_absolute_url }}">{{ course }}</a></p>
{% endfor %}
<h2>10 random courses</h2>
<p>We've selected 10 courses at random for your browsing pleasure. Feel free to contribute by adding/editing content if you know the material or, if you don't, proofreading or something. You can also view a <a href="/pages/random">random page</a> associated with a <a href="/courses/random">random course</a>.</p>
{% for course in random_courses %}
- <p style="display: inline-block; padding: 5px; text-align: center;" class="icon-thumb"><a href="{{ course.get_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course }}" /></a><br /><a href="{{ course.get_url }}">{{ course }}</a></p>
+ <p style="display: inline-block; padding: 5px; text-align: center;" class="icon-thumb"><a href="{{ course.get_absolute_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course }}" /></a><br /><a href="{{ course.get_absolute_url }}">{{ course }}</a></p>
{% endfor %}
<h2>Find a course</h2>
<p>To find the course page for a course whose department and number (e.g. MATH 133) you know, simply enter it in the search box in the top right corner. If you're not sure of the course number but know other things about it, you can use our magical <a href="/courses/search">course search wizard</a>.
@@ -47,7 +47,7 @@ <h4 id="{{ page_type.name }}">{{ page_type.long_name }}</h4>
{% endif %}
{% endfor %}
{% comment %}Done with JS, but the fallback is to go straight to the semester page (yes they exist){% endcomment %}
- <p>Filter by semester: {% for course_sem in course_sems %}<a href="{{ course_sem.get_url }}" class="semester-filter" data-semester="{{ course_sem.get_slug }}">{{ course_sem.get_semester }}</a> :: {% endfor %} <a href="" id="semester-show">Show all</a></p>
+ <p>Filter by semester: {% for course_sem in course_sems %}<a href="{{ course_sem.get_absolute_url }}" class="semester-filter" data-semester="{{ course_sem.get_slug }}">{{ course_sem.get_semester }}</a> :: {% endfor %} <a href="" id="semester-show">Show all</a></p>
</div>
</div>
{% else %}
@@ -63,7 +63,7 @@ <h4 id="{{ page_type.name }}">{{ page_type.long_name }}</h4>
<div class="span4 columns" id="right-bar">
<div class="row" style="margin-bottom: 0px;">
{% if user.is_authenticated %}
- <form method="post" action="{{ course.get_url }}/watch">
+ <form method="post" action="{{ course.get_absolute_url }}/watch">
{% csrf_token %}
{% endif %}
<div class="half-column">
@@ -81,11 +81,11 @@ <h4 id="{{ page_type.name }}">{{ page_type.long_name }}</h4>
<hr />
<div class="row">
<div class="half-column icon-thumb">
- <p><a href="{{ course.department.get_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course.department }}" /></a></p>
+ <p><a href="{{ course.department.get_absolute_url }}"><img src="{{ course.department.get_image }}" alt="{{ course.department.short_name }}" title="{{ course.department }}" /></a></p>
<p>{{ course.department }}</p>
</div>
<div class="half-column icon-thumb">
- <p><a href="{{ course.department.faculty.get_url }}"><img src="{{ course.department.faculty.get_image }}" alt="{{ course.department.faculty }}" title="{{ course.department.faculty }}" /></a></p>
+ <p><a href="{{ course.department.faculty.get_absolute_url }}"><img src="{{ course.department.faculty.get_image }}" alt="{{ course.department.faculty }}" title="{{ course.department.faculty }}" /></a></p>
<p>{{ course.department.faculty }}</p>
</div>
</div>
@@ -95,7 +95,7 @@ <h4 id="{{ page_type.name }}">{{ page_type.long_name }}</h4>
{% for item in course.recent_activity %}
<li>{{ item.user }} {{ item.action }} {% if item.page %}{{ item.page }}{% else %}this course{% endif %}</li>
{% endfor %}
- <li><a href="{{ course.get_url }}/recent">View all recent changes &raquo;</a></li>
+ <li><a href="{{ course.get_absolute_url }}/recent">View all recent changes &raquo;</a></li>
{% else %}
<li>Nothing has happened recently for this course. Boo.</li>
{% endif %}
@@ -14,7 +14,7 @@
{% if dept.courses %}
<ul class="unstyled">
{% for course in dept.courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -14,7 +14,7 @@
{% if dept.courses %}
<ul class="unstyled">
{% for course in dept.courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -5,7 +5,7 @@
<div class="container">
<section>
<ul class="breadcrumb">
- <li><a href="{{ course.get_url }}">{{ course }}</a> <span class="divider">&raquo;</span></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a> <span class="divider">&raquo;</span></li>
<li class="active">Recent activity</li>
</ul>
<h1>Recent activity</h1>
@@ -22,8 +22,8 @@
<tbody>
{% for item in history %}
<tr>
- <td>{% gravatar_img_for_user item.user 20 %} <a href="{{ item.user.get_url }}">{{ item.user.username }}</a> {% if not item.page and item.group_count %} and {{ item.group_count }} other{{ item.group_count|pluralize }}{% endif %}</td>
- <td>{{ item.action }} {% if item.page %}<a href="{{ item.page.get_url }}">{{ item.page }}</a> {% if item.group_count %}{% if item.group_count == 1 %}twice{% else %}{{ item.group_count|add:"1" }} times{% endif %}{% endif %}{% endif %}</td>
+ <td>{% gravatar_img_for_user item.user 20 %} <a href="{{ item.user.get_absolute_url }}">{{ item.user.username }}</a> {% if not item.page and item.group_count %} and {{ item.group_count }} other{{ item.group_count|pluralize }}{% endif %}</td>
+ <td>{{ item.action }} {% if item.page %}<a href="{{ item.page.get_absolute_url }}">{{ item.page }}</a> {% if item.group_count %}{% if item.group_count == 1 %}twice{% else %}{{ item.group_count|add:"1" }} times{% endif %}{% endif %}{% endif %}</td>
<td>{{ item.get_timesince}} ago</td>
</tr>
{% endfor %}
@@ -10,11 +10,11 @@
<div class="span16 columns">
<p>Shows all the courses, listed alphabetically under the relevant semester.</p>
{% for dept in departments %}
- <h2>{{ dept.long }} <small><a href="/{{ dept.short }}">&raquo; View department page</a></small></h2>
+ <h2>{{ dept.long }} <small><a href="{{ dept.get_absolute_url }}">&raquo; View department page</a></small></h2>
{% if dept.courses %}
<ul class="unstyled">
{% for course in dept.courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -24,7 +24,7 @@
<div class="row">
<div class="span1 column"><img src="{% load gravatar %}{% gravatar_for_user history_item.user 50 %}" /></div>
<div class="span11 columns">
- <p><strong><a href="{{ history_item.user.get_profile.get_url }}">{{ history_item.user.username }}</a></strong> {{ history_item.action }} {% if history_item.page %}<a href="{{ history_item.page.get_url }}">{{ history_item.page }}</a> for {% endif %} <a href="{{ history_item.course.get_url }}">{{ history_item.course }}</a> {{ history_item.get_timesince }} ago</p>
+ <p><strong><a href="{{ history_item.user.get_profile.get_absolute_url }}">{{ history_item.user.username }}</a></strong> {{ history_item.action }} {% if history_item.page %}<a href="{{ history_item.page.get_absolute_url }}">{{ history_item.page }}</a> for {% endif %} <a href="{{ history_item.course.get_absolute_url }}">{{ history_item.course }}</a> {{ history_item.get_timesince }} ago</p>
{% if history_item.message %}<p>{{ history_item.message }}</p>{% endif %}
</div>
</div>
@@ -38,7 +38,7 @@
<div class="row">
<div class="span1 column"><img src="{% load gravatar %}{% gravatar_for_user user 50 %}" /></div>
<div class="span11 columns">
- <p><strong><a href="{{ user.get_profile.get_url }}">{{ user.username }}</a></strong> {{ your_action.action }} {% if your_action.page %}<a href="{{ your_action.page.get_url }}">{{ your_action.page }}</a> for {% endif %} <a href="{{ your_action.course.get_url }}">{{ your_action.course }}</a> {{ your_action.get_timesince }} ago</p>
+ <p><strong><a href="{{ user.get_profile.get_absolute_url }}">{{ user.username }}</a></strong> {{ your_action.action }} {% if your_action.page %}<a href="{{ your_action.page.get_absolute_url }}">{{ your_action.page }}</a> for {% endif %} <a href="{{ your_action.course.get_absolute_url }}">{{ your_action.course }}</a> {{ your_action.get_timesince }} ago</p>
{% if your_action.message %}<p>{{ your_action.message }}</p>{% endif %}
</div>
</div>
@@ -52,7 +52,7 @@
{% if watched_courses %}
<ul class="unstyled">
{% for course in watched_courses %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -34,7 +34,7 @@
{% if profile.courses.count %}
<ul class="unstyled">
{% for course in profile.courses.all %}
- <li><a href="{{ course.get_url }}">{{ course }}</a></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -44,7 +44,7 @@
{% if recent_activity %}
<ul class="unstyled">
{% for activity in recent_activity %}
- <li>{{ this_user.username }} {{ activity.action }} {% if activity.page %}<a href="{{ activity.page.get_url }}">{{ activity.page }}</a> for{% endif %} <a href="{{ activity.course.get_url }}">{{ activity.course }}</a></li>
+ <li>{{ this_user.username }} {{ activity.action }} {% if activity.page %}<a href="{{ activity.page.get_absolute_url }}">{{ activity.page }}</a> for{% endif %} <a href="{{ activity.course.get_absolute_url }}">{{ activity.course }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -58,7 +58,7 @@
{% if user_pages %}
<ul>
{% for page in user_pages %}
- <li><a href="{{ page.get_url }}">{{ page.course_sem.course }} {{ page }}</a></li>
+ <li><a href="{{ page.get_absolute_url }}">{{ page.course_sem.course }} {{ page }}</a></li>
{% endfor %}
</ul>
{% else %}
@@ -23,8 +23,8 @@
<tr>
<td>{% gravatar_img_for_email event.user.email 20 %} {{ event.user }}</td>
<td>{{ event.action }}</td>
- <td>{% if event.page %}<a href="{{ event.page.get_url }}">{{ event.page }}</a> (view changes - later){% else %}N/A{% endif %}</td>
- <td><a href="{{ event.course.get_url }}">{{ event.course }}</a></td>
+ <td>{% if event.page %}<a href="{{ event.page.get_absolute_url }}">{{ event.page }}</a> (view changes - later){% else %}N/A{% endif %}</td>
+ <td><a href="{{ event.course.get_absolute_url }}">{{ event.course }}</a></td>
<td>{{ event.get_timesince }} ago</td>
</tr>
{% endfor %}
View
@@ -7,7 +7,7 @@
<div class="row">
<div class="span12">
{% for post in blog_posts %}
- <h2><a href="{{ post.get_url }}">{{ post.title }}</a></h2>
+ <h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<hr />
<h4 class="float-right">{{ post.timestamp }}</h4>
<h4>{{ post.get_num_comments }} comment{{ post.get_num_comments|pluralize }}</h4>
@@ -5,19 +5,19 @@
<div class="container">
<section>
<ul class="breadcrumb">
- <li><a href="{{ course.get_url }}">{{ course }}</a> <span class="divider">&raquo;</span></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a> <span class="divider">&raquo;</span></li>
<li><a href="#">{{ page.course_sem.term.title }} {{ page.course_sem.year }}</a> <span class="divider">&raquo;</span></li>
<li><a href="#">{{ page.get_type.long_name }}</a> <span class="divider">&raquo;</span><li>
- <li><a href="{{ page.get_url }}">{{ page.get_title }}</a> <span class="divider">&raquo;</span></li>
- <li><a href="{{ page.get_url }}/history">History</a> <span class="divider">&raquo;</span></li>
+ <li><a href="{{ page.get_absolute_url }}">{{ page.get_title }}</a> <span class="divider">&raquo;</span></li>
+ <li><a href="{{ page.get_absolute_url }}/history">History</a> <span class="divider">&raquo;</span></li>
<li class="active">Viewing commit</li>
</ul>
<h1>Commit {{ hash }}</h1>
<hr />
<div class="grey-box">
<div class="row">
<div class="span2 icon-thumb center-align">
- <a href="{{ commit.author.get_url }}"><img src="{% gravatar_for_user commit.author 100 %}" /></a>
+ <a href="{{ commit.author.get_absolute_url }}"><img src="{% gravatar_for_user commit.author 100 %}" /></a>
{{ commit.author }}
</div>
<div class="span14">
@@ -1,2 +1,2 @@
-<td><a href="{{ page.get_url }}">{{ page.subject }}</a></td>
+<td><a href="{{ page.get_absolute_url }}">{{ page.subject }}</a></td>
<td>{{ page.course_sem.get_semester }}</td>
@@ -6,7 +6,7 @@
<div class="row">
<h1>Creating a page :: {{ page_type.long_name }}</h1>
<ul class="breadcrumb">
- <li><a href="{{ course.get_url }}">{{ course }}</a> <span class="divider">&raquo;</span></li>
+ <li><a href="{{ course.get_absolute_url }}">{{ course }}</a> <span class="divider">&raquo;</span></li>
<li><a href="#">{{ page_type.long_name }}</a> <span class="divider">&raquo;</span><li>
<li class="active">{% if edit_mode %}Edit{% else %}Create{% endif %}</li>
</ul>
Oops, something went wrong.

0 comments on commit a094048

Please sign in to comment.