Skip to content
/ todo Public

try out if I can migrate stas' todo work here to comment better

Notifications You must be signed in to change notification settings

Pike/todo

Repository files navigation

Installation

  1. Put the todo directory in your Python path.
  2. Add todo to your INSTALLED_APPS setting.
  3. Add the following line to your global URL patterns:

    (r'^todo/', include('todo.urls')),

  4. Sync the database.
  5. Copy todo/static to wherever you serve your static files from.
  6. Include the following code snippet in the HEAD section of every view that will display todo's snippets:

    <link rel="stylesheet" type="text/css" href="{% url static path='todo/todo.css' %}" />
    
    <style type="text/css">
        .todo #outofdate {
            background-image: url({% url static path="todo/warning.png" %});
        }
        .todo #uptodate {
            background-image: url({% url static path="todo/okay.png" %});
        }
        .todo #checking div {
            background: url({% url static path="loadingAnimation.gif" %}) no-repeat 0 13px;
        }
    </style>

Configuration

Settings

The todo app logs every action perfomed on the todo objects using the Django admin's LogEntry model. Each action has a corresponding numerical flag. For example, the default flag for object creation in the LogEntry model is 1.

The todo app uses its own action flags. Internally, they start with 1 and go up. In order to avoid conflicts with the default admin's flags, you can set a TODO_FLAG_OFFSET setting in your `settings.py`:

``TODO_FLAG_OFFSET = 20``

The value of the offset will be automatically added to all flags used by the todo app. For the exmaple above, if the flag for the activation action is 3, the value of the flag saved in admin's LogEntry will be 23.

The default value is 10.

Integration

In order to enable todo for your app, follow these steps:

#. Add a one-to-one relation to your app's project model definition pointing to todo.models.Project with `related_name="origin"`:

from todo.models import Project as TodoProject

class YourProject(models.Model):
    ...
    todo = models.OneToOneField(TodoProject, related_name="origin")
  1. Create or modify views where you want to use the todo snippets. You must have at least two views:

    • a single task view,
    • a single tracker view.

    These two views are required. Additionally, you might want to create:

    • a single project view,
    • a single locale view,
    • a combined (project+locale) view.

    You might want to modify your app's URL patterns like so:

    urlpatterns += patterns('yourapp.views',
        (r'^task/(?P<task_id>\d+)$', 'single_task'), 
        (r'^tracker/(?P<tracker_id>\d+)$', 'single_tracker'), 
    )

    (Add more URL patterns if you have more views.)

    Here's an example of how these views can look like:

    from django.shortcuts import get_object_or_404, render_to_response
    from django.utils.safestring import mark_safe
    
    from todo.views import snippets
    
    def single_task(request, task_id):
        from todo.models import Task
        task = get_object_or_404(Task, pk=task_id)
        task_div = snippets.task(request, task,
                                 redirect_view='yourapp.views.single_task')
        task_div = mark_safe(task_div)
        return render_to_response('yourapp/single_task.html',
                                  {'task_div': task_div,})
    
    def single_tracker(request, tracker_id):
        from todo.models import Tracker
        tracker = get_object_or_404(Tracker, pk=tracker_id)
        tree_div = snippets.tree(request, tracker=tracker,
                                 project=None, locale=None,
                                 task_view='yourapp.views.single_task',
                                 tracker_view='yourapp.views.single_tracker')
        tree_div = mark_safe(tree_div)
        return render_to_response('yourapp/single_tracker.html',
                                  {'tree_div': tree_div,})

    See todo.views.snippets and todo.views.demo for more documentation.

  2. Add the todo snippets' divs to your templates. Wrap them in a div with the todo class. For example:

    <div class="todo">{{task_div}}</div>

    or

    <div class="todo">{{tree_div}}</div>

About

try out if I can migrate stas' todo work here to comment better

Resources

Stars

Watchers

Forks

Packages

No packages published