Commits

Anonymous committed c8c2deb

more django 1.5 changes for urls

Comments (0)

Files changed (15)

fitlog/templates/fitlog/add_cardio.html

 {% block body %}
 
 <h1>Add Cardio Log</h1>
-<form method="post" action="{% url add_cardio fitlog.id %}">
+<form method="post" action="{% url 'add_cardio' fitlog.id %}">
 <table>
     {{form}}
 <tr><td colspan='2'><input type="submit" value="Save" /></td></tr>

fitlog/templates/fitlog/add_weight_training.html

 {% block body %}
 
 <h1>Add Weight Training Log</h1>
-<form method="post" action="{% url add_weight_training_log fitlog.id %}">
+<form method="post" action="{% url 'add_weight_training_log' fitlog.id %}">
 <table>
     {{form}}
 

fitlog/templates/fitlog/base.html

     </head>
     <body>      
         {% if user.is_authenticated %}
-        <a href='{% url home %}'>Home</a> <a href='{% url auth_logout %}'>logout</a>
+        <a href='{% url 'home' %}'>Home</a> <a href='{% url 'auth_logout' %}'>logout</a>
         {% endif %} 
         {% block body %}{% endblock body %}
         <br />

fitlog/templates/fitlog/bodyweight_log.html

 {% load pagination_tags %}
 
 {% block body %}
-<a href='{% url add_bodyweight_log %}'>Add New Body Weight Log</a>
+<a href='{% url 'add_bodyweight_log' %}'>Add New Body Weight Log</a>
 
 <h1>Body Weight Log</h1>
 {% autopaginate bodyweight_log %}
     </table>
 {% paginate %}
 
-<a href='{% url add_bodyweight_log %}'>Add New Body Weight Log</a>
+<a href='{% url 'add_bodyweight_log' %}'>Add New Body Weight Log</a>
 
 {% endblock body %}

fitlog/templates/fitlog/edit_fitlog.html

 {% block body %}
 
 <h1>Add Fitness Log</h1>
-<form method="post" action="{% url edit_fitlog fitlog.id %}">
+<form method="post" action="{% url 'edit_fitlog' fitlog.id %}">
 <table>
     {{form}}
 <tr><td colspan='2'><input type="submit" value="Save" /></td></tr>

fitlog/templates/fitlog/fitlog.html

 {% extends "fitlog/base.html" %}
 {% load fitlog_tags %}
 {% block body %}
-<a href='{% url add_log %}'>Add New Fitness Log</a>
+<a href='{% url 'add_log' %}'>Add New Fitness Log</a>
 
 <h1>FitLog</h1>
 {% ifequal fitlog.member.id user.id %}
-    [<a href='{% url edit_fitlog fitlog.id %}'>Edit FitLog</a>]
+    [<a href='{% url 'edit_fitlog' fitlog.id %}'>Edit FitLog</a>]
 {% endifequal %}
 {% view_fitlog_detail fitlog %}
 
 <h2>Cardio</h2>
 {% ifequal fitlog.member.id user.id %}
-    [<a href='{% url add_cardio fitlog.id %}'>Add Cardio</a>]
+    [<a href='{% url 'add_cardio' fitlog.id %}'>Add Cardio</a>]
 {% endifequal %}
 {% cardio_list fitlog %}
 
 <h2>Weight Training</h2>
 {% ifequal fitlog.member.id user.id %}
-    [<a href='{% url add_weight_training_log fitlog.id %}'>Add Weight Training</a>]
+    [<a href='{% url 'add_weight_training_log' fitlog.id %}'>Add Weight Training</a>]
 {% endifequal %}
 {% weight_training_list fitlog %}
 

fitlog/templates/fitlog/home.html

 
 {% if user.is_authenticated %}
     <p>Welcome, {{ user.username }}. Thanks for logging in. 
-    <a href='{% url my_logs %}'>View My Logs</a> 
-    or <a href='{% url add_log %}'>Add New Fitness Log</a>
-    or <a href='{% url bodyweight_log %}'>View My Body Weight Log</a> </p>
+    <a href='{% url 'my_logs' %}'>View My Logs</a>
+    or <a href='{% url 'add_log' %}'>Add New Fitness Log</a>
+    or <a href='{% url 'bodyweight_log' %}'>View My Body Weight Log</a> </p>
         
     <h2>Newest Fitness Logs</h2>
     {% list_recent_logs %}
         
 {% else %}
     <p>Welcome, new user. Please log in or register to gain access</p>
-    <a href='{% url auth_login %}'>Login</a>
-    <a href='{% url registration_register %}'>Register</a>
+    <a href='{% url 'auth_login' %}'>Login</a>
+    <a href='{% url 'registration_register' %}'>Register</a>
 {% endif %}
 
 {% endblock body %}

fitlog/templates/fitlog/my_logs.html

 {% extends "fitlog/base.html" %}
 {% load fitlog_tags %}
 {% block body %}
-<a href='{% url add_log %}'>Add New Fitness Log</a>
+<a href='{% url 'add_log' %}'>Add New Fitness Log</a>
 
 <h1>{{user}}'s Fitness Logs</h1>
 

fitlog/templates/fitlog/tags/list_logs.html

         <tr><td>{{log.member}}</td><td>{{log.log_date|default_if_none:"n/a"}}</td><td>{{log.title|default_if_none:"-"}}</td><td>{{log.total_time|default_if_none:"-"}}</td>
         <td>{{log.total_exercises|default_if_none:"-"}}</td><td>{{log.total_sets|default_if_none:"-"}}</td><td>{{log.total_reps|default_if_none:"-"}}</td>
         <td>{{log.training_volume|default_if_none:"-"}}</td><td>{{log.cardio_min|default_if_none:"-"}}</td><td>{{log.cardio_distance|default_if_none:"-"}}</td>
-        <td>{{log.comments|linebreaksbr}}</td><td>[<a href='{% url view_fitlog log.id%}'>View</a>]</td></tr>
+        <td>{{log.comments|linebreaksbr}}</td><td>[<a href='{% url 'view_fitlog' log.id%}'>View</a>]</td></tr>
     {% endfor %}
         </tbody>
     </table>

fitlog/templates/fitlog/tags/stats.html

 <tr><th>Members: {{num_members}}</th></tr>
 <tr><th>FitLogs : {{num_logs}}</th></tr>
 </table>
-<a href='{% url changelog %}'>0.1.1</a>
+<a href='{% url 'changelog' %}'>0.1.1</a>

fitlog/templates/login.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Signin" %}{% endblock title %}
+
+{% block right-side %}{% endblock right-side %}
+
+{% block body %}
+    <form action="" method="post">{% csrf_token %}
+    {{ form.non_field_errors }}
+    {% for field in form %}
+        {{ field.errors }}
+    {% endfor %}
+
+    {{ form.as_p }}
+
+    <input type="submit" value="{% trans "Signin" %}" />
+
+    </form>
+</div>
+{% endblock body %}

fitlog/templates/logout.html

+{% extends 'base.html' %}
+{% load i18n %}
+
+{% block title %}{% trans "Signed out" %}{% endblock title %}
+{% block content_title %}<h2>{% trans "You have been signed out" %}.</h2>{% endblock content_title %}
+
+{% block body %}
+<p>{% trans "You have been signed out." %}</p>
+{% endblock body %}

fitlog/templatetags/fitlog_tags.py

 @register.inclusion_tag('fitlog/tags/list_logs.html',takes_context=True)
 def list_recent_logs(context):
     fit_logs = FitLog.objects.latest()   
-    return { 'fit_logs' : fit_logs,"request":context['request'] }
+    return {'fit_logs': fit_logs, "request": context.get('request')}
 
 @register.inclusion_tag('fitlog/tags/list_logs.html',takes_context=True)
 def list_user_logs(context,username):
     try:
         user = User.objects.get(username=username)
         fit_logs = FitLog.objects.by_member(user)   
-        return { 'fit_logs' : fit_logs,"request":context['request'] }
+        return {'fit_logs': fit_logs, "request":context.get('request')}
     except User.DoesNotExist:
         pass
-    return {"request":context['request']}
+    return {"request":context.get('request')}
 
 @register.inclusion_tag('fitlog/tags/stats.html',takes_context=True)
 def stats(context):
     num_logs = FitLog.objects.number_of_logs()
     num_members = User.objects.filter(is_active=True).count()  
-    return { 'num_logs' : num_logs,'num_members':num_members, "request":context['request'] }
+    return {'num_logs' : num_logs,'num_members':num_members,
+            "request":context.get('request')}
 
 @register.inclusion_tag('fitlog/tags/weight_training_list.html')
 def weight_training_list(fitlog): 
 from django.conf.urls import patterns, url
 from django.views.generic import TemplateView
+from django.contrib.auth import views as auth_views
 
 from fitlog import views
 
     url(r'^changelog/$', TemplateView.as_view(
          template_name='fitlog/changelog.html'), name='changelog'),
 )
+
+# for login/logout
+urlpatterns += patterns(
+    '',
+    url(r'^login/$', auth_views.login, {'template_name': 'login.html'},
+        name='auth_login'),
+    url(r'^logout/$', auth_views.logout, {'template_name': 'logout.html'},
+        name='auth_logout'),
+)
     install_requires=[
         "Django >= 1.5.1",
         "South==0.7.6",
+        "django-pagination==1.0.7",
     ],
 )
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.