Commits

Rafał Selewońko committed 754dd4e

zmiana nazwy z worklog na task a worklogentry na worklog

  • Participants
  • Parent commits 370f562

Comments (0)

Files changed (10)

templates/worklogs/report.html

     <input type="text" id="to" name="to" value="{{ to.isoformat }}"/>
     <input type="submit" />
 </form>
-{% if time_per_worklog %}
+{% if time_per_task %}
 <div id="reports">
     <ul>
-        <li><a href="#time_per_worklog">{% trans "time per worklog" %}</a></li>
-        <li><a href="#worklogs_per_day">{% trans "worklogs per day" %}</a></li>
+        <li><a href="#time_per_task">{% trans "time per task" %}</a></li>
+        <li><a href="#tasks_per_day">{% trans "tasks per day" %}</a></li>
         <li><a href="#time_per_project">{% trans "time per project" %}</a></li>
     </ul>
-    <div id="time_per_worklog">
+    <div id="time_per_task">
     <textarea class="copy" rows="24" cols="80">{% if from != to %}{{ from }} - {{ to }}
-{% endif %}{% for worklog, duration in time_per_worklog %}
-{{ worklog.description }} ({{duration|seconds_to_time}}) - {{ worklog.get_state_display }}
-{{ worklog.bugtracker_url }}
+{% endif %}{% for task, duration in time_per_task %}
+{{ task.description }} ({{duration|seconds_to_time}}) - {{ task.get_state_display }}
+{{ task.bugtracker_url }}
 {% endfor %}</textarea>
     </div>
-    <div id="worklogs_per_day">
+    <div id="tasks_per_day">
     <textarea class="copy" rows="24" cols="80">{% if from != to %}{{ from }} - {{ to }}
-{% endif %}{% for date, data in worklogs_per_day.items %}
+{% endif %}{% for date, data in tasks_per_day.items %}
 {{ date }} ({{ data.time|seconds_to_time }}):
-    {% for worklog, duration in data.worklogs %}
-    {{ worklog.description }} ({{duration|seconds_to_time}})
-    {{ worklog.bugtracker_url }}
+    {% for task, duration in data.tasks %}
+    {{ task.description }} ({{duration|seconds_to_time}})
+    {{ task.bugtracker_url }}
     {% endfor %}{% endfor %}</textarea>
     </div>
     <div id="time_per_project">
 {% endif %}{% for project, data in time_per_project.items %}
 {{ project }}: {{ data.time|seconds_to_hours:2|floatformat }}h{% endfor %}</textarea>
     </div>
-</div>{% else %}{% trans "No worklogs in selected date range" %}{% endif %}
+</div>{% else %}{% trans "No tasks in selected date range" %}{% endif %}
 </div>
 
 {% endblock %}

worklogs/admin.py

 from django.utils.translation import ugettext_lazy as _
 from django.contrib.admin.templatetags.admin_list import _boolean_icon
 
-from .models import WorkLog, WorkLogEntry, Project, BugTracker
-from .urls import worklog_admin_urls
-from .forms import WorkLogAddForm
+from .models import Task, WorkLog, Project, BugTracker
+from .urls import task_admin_urls
+from .forms import TaskAddForm
 
 
-class WorkLogAdmin(admin.ModelAdmin):
-    add_form = WorkLogAddForm
+class TaskAdmin(admin.ModelAdmin):
+    add_form = TaskAddForm
     date_hierarchy = 'mod_date'
     list_display = (
         'get_bugtracker_id',
     list_select_related = True
     search_fields = ('description', 'worklog_entries__description', 'bugtracker_object_id')
 
-    def get_bugtracker_id(self, worklog):
-        return '#%s' % worklog.bugtracker_object_id
+    def get_bugtracker_id(self, task):
+        return '#%s' % task.bugtracker_object_id
     get_bugtracker_id.short_description = _(u"#")
 
-    def get_duration_display(self, worklog):
+    def get_duration_display(self, task):
         kwargs = {
-            'duration_formatted': worklog.get_duration_display(),
-            'duration': worklog.duration,
+            'duration_formatted': task.get_duration_display(),
+            'duration': task.duration,
         }
-        if worklog.active:
-            return """<span class="worklog_duration d{duration}s">
+        if task.active:
+            return """<span class="task_duration d{duration}s">
     {duration_formatted}
 </span>""".format(**kwargs)
         else:
     get_duration_display.allow_tags = True
     get_duration_display.short_description = _(u"duration")
 
-    def toggle_active_button(self, worklog):
-        if worklog.active:
+    def toggle_active_button(self, task):
+        if task.active:
             link = """<a href="stop/{id}/" title="click to stop">{icon} stop</a>"""
         else:
             link = """<a href="start/{id}/" title="click to start">{icon} start</a>"""
-        return link.format(id=worklog.id, icon=_boolean_icon(worklog.active))
+        return link.format(id=task.id, icon=_boolean_icon(task.active))
     toggle_active_button.allow_tags = True
     toggle_active_button.short_description = _(u"toggle")
 
-    def bugtracker_link(self, worklog):
-        return """<a href="%s">%s/%s<a>""" % (worklog.bugtracker_url(), worklog.bugtracker.name, worklog.bugtracker_object_id)
+    def bugtracker_link(self, task):
+        return """<a href="%s">%s/%s<a>""" % (task.bugtracker_url(), task.bugtracker.name, task.bugtracker_object_id)
     bugtracker_link.allow_tags = True
     bugtracker_link.short_description = _("bugtracker")
 
-    def project_link(self, worklog):
-        url = worklog.project.url
-        name = worklog.project.name
+    def project_link(self, task):
+        url = task.project.url
+        name = task.project.name
         if url:
             return u"""<a href="{url}">{name}</a>""".format(url=url, name=name)
         else:
                 'form': self.add_form,
             })
         defaults.update(kwargs)
-        return super(WorkLogAdmin, self).get_form(request, obj, **defaults)
+        return super(TaskAdmin, self).get_form(request, obj, **defaults)
 
     def get_urls(self):
-        urls = super(WorkLogAdmin, self).get_urls()
-        return worklog_admin_urls + urls
+        urls = super(TaskAdmin, self).get_urls()
+        return task_admin_urls + urls
 
     class Media:
         css = {
         )
 
 
-admin.site.register(WorkLog, WorkLogAdmin)
-admin.site.register((WorkLogEntry, Project, BugTracker))
+admin.site.register(Task, TaskAdmin)
+admin.site.register((WorkLog, Project, BugTracker))

worklogs/forms.py

 from django.conf import settings
 from django.utils.translation import ugettext_lazy as _
 
-from .models import WorkLog
+from .models import Task
 
 
-class WorkLogAddForm(forms.ModelForm):
+class TaskAddForm(forms.ModelForm):
 
     class Meta:
-        model = WorkLog
+        model = Task
         exclude = ('active', 'duration')

worklogs/managers.py

 from django.db import models
 
 
-class WorkLogManager(models.Manager):
+class TaskManager(models.Manager):
     def recent(self, days=0):
         today = datetime.date.today()
         start = today - datetime.timedelta(days=days)
         return self.get_query_set().filter(add_date__gte=start, mod_date__lt=end)
 
     def stop_active(self):
-        worklog_queryset = self.get_query_set().filter(active=True)
-        if worklog_queryset.exists():
-            worklog = worklog_queryset.get()
-            worklog.stop()
-            return worklog
+        task_queryset = self.get_query_set().filter(active=True)
+        if task_queryset.exists():
+            task = task_queryset.get()
+            task.stop()
+            return task
         else:
             return False
 
 
-class WorkLogEntryManager(models.Manager):
+class WorkLogManager(models.Manager):
     def in_range(self, from_date, to_date):
         start = datetime.datetime.combine(from_date, datetime.time())
         end = datetime.datetime.combine(to_date + datetime.timedelta(days=1), datetime.time())

worklogs/migrations/0003_auto__del_worklogentry__del_worklog__add_task__add_taskentry.py

+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Deleting model 'WorkLogEntry'
+        db.delete_table('worklogs_worklogentry')
+
+        # Deleting model 'WorkLog'
+        db.delete_table('worklogs_worklog')
+
+        # Adding model 'Task'
+        db.create_table('worklogs_task', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('active', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('description', self.gf('django.db.models.fields.CharField')(max_length=1024)),
+            ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklogs', to=orm['auth.User'])),
+            ('project', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklogs', to=orm['worklogs.Project'])),
+            ('bugtracker', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='worklogs', null=True, to=orm['worklogs.BugTracker'])),
+            ('bugtracker_object_id', self.gf('django.db.models.fields.CharField')(max_length=16, null=True, blank=True)),
+            ('duration', self.gf('django.db.models.fields.PositiveIntegerField')(null=True, blank=True)),
+            ('add_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+            ('mod_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
+            ('state', self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=0)),
+            ('eta', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=8, decimal_places=4, blank=True)),
+        ))
+        db.send_create_signal('worklogs', ['Task'])
+
+        # Adding model 'TaskEntry'
+        db.create_table('worklogs_taskentry', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
+            ('description', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True, blank=True)),
+            ('worklog', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklog_entries', to=orm['worklogs.Task'])),
+            ('start', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+            ('end', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+        ))
+        db.send_create_signal('worklogs', ['TaskEntry'])
+
+    def backwards(self, orm):
+        # Adding model 'WorkLogEntry'
+        db.create_table('worklogs_worklogentry', (
+            ('end', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+            ('description', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True, blank=True)),
+            ('start', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+            ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
+            ('worklog', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklog_entries', to=orm['worklogs.WorkLog'])),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+        ))
+        db.send_create_signal('worklogs', ['WorkLogEntry'])
+
+        # Adding model 'WorkLog'
+        db.create_table('worklogs_worklog', (
+            ('description', self.gf('django.db.models.fields.CharField')(max_length=1024)),
+            ('duration', self.gf('django.db.models.fields.PositiveIntegerField')(null=True, blank=True)),
+            ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklogs', to=orm['auth.User'])),
+            ('mod_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
+            ('active', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('eta', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=8, decimal_places=4, blank=True)),
+            ('add_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+            ('project', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklogs', to=orm['worklogs.Project'])),
+            ('state', self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=0)),
+            ('bugtracker_object_id', self.gf('django.db.models.fields.CharField')(max_length=16, null=True, blank=True)),
+            ('bugtracker', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklogs', null=True, to=orm['worklogs.BugTracker'], blank=True)),
+        ))
+        db.send_create_signal('worklogs', ['WorkLog'])
+
+        # Deleting model 'Task'
+        db.delete_table('worklogs_task')
+
+        # Deleting model 'TaskEntry'
+        db.delete_table('worklogs_taskentry')
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'worklogs.bugtracker': {
+            'Meta': {'object_name': 'BugTracker'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'url_pattern': ('django.db.models.fields.CharField', [], {'max_length': '256'})
+        },
+        'worklogs.project': {
+            'Meta': {'object_name': 'Project'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+        },
+        'worklogs.task': {
+            'Meta': {'ordering': "('-add_date',)", 'object_name': 'Task'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'add_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'bugtracker': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'worklogs'", 'null': 'True', 'to': "orm['worklogs.BugTracker']"}),
+            'bugtracker_object_id': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+            'duration': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'eta': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '8', 'decimal_places': '4', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mod_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'worklogs'", 'to': "orm['worklogs.Project']"}),
+            'state': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'worklogs'", 'to': "orm['auth.User']"})
+        },
+        'worklogs.taskentry': {
+            'Meta': {'ordering': "('-start',)", 'object_name': 'TaskEntry'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+            'end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'start': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'worklog': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'worklog_entries'", 'to': "orm['worklogs.Task']"})
+        }
+    }
+
+    complete_apps = ['worklogs']

worklogs/migrations/0004_auto__del_taskentry__add_worklog.py

+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Deleting model 'TaskEntry'
+        db.delete_table('worklogs_taskentry')
+
+        # Adding model 'WorkLog'
+        db.create_table('worklogs_worklog', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
+            ('description', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True, blank=True)),
+            ('worklog', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklog_entries', to=orm['worklogs.Task'])),
+            ('start', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+            ('end', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+        ))
+        db.send_create_signal('worklogs', ['WorkLog'])
+
+    def backwards(self, orm):
+        # Adding model 'TaskEntry'
+        db.create_table('worklogs_taskentry', (
+            ('end', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+            ('description', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True, blank=True)),
+            ('start', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+            ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
+            ('worklog', self.gf('django.db.models.fields.related.ForeignKey')(related_name='worklog_entries', to=orm['worklogs.Task'])),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+        ))
+        db.send_create_signal('worklogs', ['TaskEntry'])
+
+        # Deleting model 'WorkLog'
+        db.delete_table('worklogs_worklog')
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'worklogs.bugtracker': {
+            'Meta': {'object_name': 'BugTracker'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'url_pattern': ('django.db.models.fields.CharField', [], {'max_length': '256'})
+        },
+        'worklogs.project': {
+            'Meta': {'object_name': 'Project'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+        },
+        'worklogs.task': {
+            'Meta': {'ordering': "('-add_date',)", 'object_name': 'Task'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'add_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'bugtracker': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'worklogs'", 'null': 'True', 'to': "orm['worklogs.BugTracker']"}),
+            'bugtracker_object_id': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+            'duration': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'eta': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '8', 'decimal_places': '4', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mod_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'worklogs'", 'to': "orm['worklogs.Project']"}),
+            'state': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'worklogs'", 'to': "orm['auth.User']"})
+        },
+        'worklogs.worklog': {
+            'Meta': {'ordering': "('-start',)", 'object_name': 'WorkLog'},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+            'end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'start': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'worklog': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'worklog_entries'", 'to': "orm['worklogs.Task']"})
+        }
+    }
+
+    complete_apps = ['worklogs']

worklogs/migrations/0005_auto__del_field_worklog_worklog__add_field_worklog_task.py

+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Deleting field 'WorkLog.worklog'
+        db.rename_column('worklogs_worklog', 'worklog_id', 'task_id')
+
+    def backwards(self, orm):
+
+        db.rename_column('worklogs_worklog', 'task_id', 'worklog_id')

worklogs/models.py

 from django.utils.translation import ugettext_lazy as _
 from django.core.urlresolvers import reverse
 
-from .managers import WorkLogManager, WorkLogEntryManager
+from .managers import TaskManager, WorkLogManager
 
 
 def firstof(*items):
             return i
 
 
-class WorkLog(models.Model):
+class Task(models.Model):
     STATE_NEW = 0
     STATE_IN_PROGRESS = 1
     STATE_WAITING = 2
 
     user = models.ForeignKey('auth.User',
                     verbose_name=_(u'user'),
-                    related_name='worklogs')
+                    related_name='tasks')
 
     project = models.ForeignKey('Project',
                     verbose_name=_(u'project'),
-                    related_name='worklogs')
+                    related_name='tasks')
 
     bugtracker = models.ForeignKey('BugTracker',
             blank=True,
             null=True,
             verbose_name=_(u'bugtracker'),
-            related_name='worklogs')
+            related_name='tasks')
 
     bugtracker_object_id = models.CharField(
             blank=True,
             null=True,
             verbose_name=_(u"eta (hours)"))
 
-    objects = WorkLogManager()
+    objects = TaskManager()
 
     class Meta:
-        verbose_name = _(u'work log')
-        verbose_name_plural = _(u'work logs')
+        verbose_name = _(u'task')
+        verbose_name_plural = _(u'tasks')
         ordering = ('-add_date',)
         get_latest_by = 'add_date'
 
         return self.description
 
     def get_absolute_url(self):
-        return reverse('worklog', args=[self.pk])
+        return reverse('task', args=[self.pk])
 
     def bugtracker_url(self):
         return self.bugtracker.url_pattern.format(id=self.bugtracker_object_id)
 
     def start(self, description=None):
-        # stop active WorkLog
-        WorkLog.objects.stop_active()
+        # stop active Task
+        Task.objects.stop_active()
 
         # mark self active
         self.active = True
         self.save()
 
-        # create new WorkLogEntry for this WorkLog
-        WorkLogEntry.objects.create(worklog=self, description=description)
+        # create new WorkLog for this Task
+        WorkLog.objects.create(task=self, description=description)
 
     def stop(self):
         try:
-            active_entry = self.worklog_entries.filter(active=True).get()
-        except WorkLogEntry.DoesNotExist:
+            active_entry = self.task_entries.filter(active=True).get()
+        except WorkLog.DoesNotExist:
             pass
         else:
             active_entry.stop()
         self.save()
 
     def _calculate_duration(self):
-        return sum(map(lambda e: e.duration, self.worklog_entries.all()))
+        return sum(map(lambda e: e.duration, self.task_entries.all()))
 
     def update_duration(self):
         self.duration = self._calculate_duration()
     get_eta_display.short_description = _(u"eta")
 
 
-class WorkLogEntry(models.Model):
+class WorkLog(models.Model):
     active = models.BooleanField(
             default=True,
             verbose_name=_(u'active'))
                     max_length=1024,
                     verbose_name=_(u'description'))
 
-    worklog = models.ForeignKey('WorkLog',
-                    verbose_name=_(u'worklog'),
-                    related_name='worklog_entries')
+    task = models.ForeignKey('Task',
+                    verbose_name=_(u'task'),
+                    related_name='worklogs')
 
     start = models.DateTimeField(
                     default=datetime.datetime.now,
 #            null=True,
 #            verbose_name=_(u"cleared"))
 
-    objects = WorkLogEntryManager()
+    objects = WorkLogManager()
 
     class Meta:
-        verbose_name = _(u'work log entry')
-        verbose_name_plural = _(u'work log entries')
+        verbose_name = _(u'worklog')
+        verbose_name_plural = _(u'worklogs')
         ordering = ('-start',)
         get_latest_by = 'start'
 
 
 from django.conf.urls.defaults import patterns, url
 
-from .views import worklog_start, worklog_stop, report
+from .views import task_start, task_stop, report
 
 urlpatterns = patterns('',
     url(r'^$', report, name='report'),
 )
 
-worklog_admin_urls = patterns('',
-    url(r'^start/(?P<object_id>\d+)/$', worklog_start, name='worklog_start'),
-    url(r'^stop/(?P<object_id>\d+)/$', worklog_stop, name='worklog_stop'),
+task_admin_urls = patterns('',
+    url(r'^start/(?P<object_id>\d+)/$', task_start, name='task_start'),
+    url(r'^stop/(?P<object_id>\d+)/$', task_stop, name='task_stop'),
 )
 

worklogs/views.py

 from django.shortcuts import render_to_response
 from django.utils.translation import ugettext as _
 
-from .models import WorkLog, WorkLogEntry
+from .models import Task, WorkLog
 
 current_year = lambda: datetime.datetime.now().isocalendar()[0]
 current_week = lambda: datetime.datetime.now().isocalendar()[1]
 
 
 @login_required
-def worklog_start(request, object_id):
-    worklog = WorkLog.objects.get(id=object_id)
-    if request.user == worklog.user or request.user.is_superuser:
+def task_start(request, object_id):
+    task = Task.objects.get(id=object_id)
+    if request.user == task.user or request.user.is_superuser:
         # FIXME: zamienic na "user_passes_test"
-        worklog.start()
-        messages.success(request, _(u'WorkLog "{}" has been started.').format(worklog))
+        task.start()
+        messages.success(request, _(u'Task "{}" has been started.').format(task))
     else:
-        messages.error(request, _(u'WorkLog "{}" has <b>not</b> been started. Insufficient permissions.').format(worklog))
-    return HttpResponseRedirect('/worklogs/worklog/')
+        messages.error(request, _(u'Task "{}" has <b>not</b> been started. Insufficient permissions.').format(task))
+    return HttpResponseRedirect('/worklogs/task/')
 
 
 @login_required
-def worklog_stop(request, object_id):
-    worklog = WorkLog.objects.get(id=object_id)
-    if request.user == worklog.user or request.user.is_superuser:
+def task_stop(request, object_id):
+    task = Task.objects.get(id=object_id)
+    if request.user == task.user or request.user.is_superuser:
         # FIXME: zamienic na "user_passes_test"
-        worklog.stop()
-        messages.success(request, _(u'WorkLog "{}" has been stopped.').format(worklog))
+        task.stop()
+        messages.success(request, _(u'Task "{}" has been stopped.').format(task))
     else:
-        messages.error(request, _(u'WorkLog "{}" has <b>not</b> been stopped. Insufficient permissions.').format(worklog))
-    return HttpResponseRedirect('/worklogs/worklog/')
+        messages.error(request, _(u'Task "{}" has <b>not</b> been stopped. Insufficient permissions.').format(task))
+    return HttpResponseRedirect('/worklogs/task/')
 
 
 @login_required
     else:
         to_date = from_date + datetime.timedelta(days=5)
 
-    entries = WorkLogEntry.objects.in_range(from_date, to_date).filter(worklog__user=request.user)
+    entries = WorkLog.objects.in_range(from_date, to_date).filter(task__user=request.user)
 
     time_per_project = {}
-    time_per_worklog = []
-    worklogs_per_day = {}
+    time_per_task = []
+    tasks_per_day = {}
 
     for entry in entries:
         try:
-            index = list(map(lambda a: a[0].id, time_per_worklog)).index(entry.worklog.id)
+            index = list(map(lambda a: a[0].id, time_per_task)).index(entry.task.id)
         except ValueError:
-            time_per_worklog.append([entry.worklog, entry.duration])
+            time_per_task.append([entry.task, entry.duration])
         else:
-            time_per_worklog[index][1] += entry.duration
+            time_per_task[index][1] += entry.duration
 
         date = entry.start.date()
-        if date in worklogs_per_day:
+        if date in tasks_per_day:
             try:
-                index = list(map(lambda a: a[0].id, worklogs_per_day[date]['worklogs'])).index(entry.worklog.id)
+                index = list(map(lambda a: a[0].id, tasks_per_day[date]['tasks'])).index(entry.task.id)
             except ValueError:
-                worklogs_per_day[date]['worklogs'].append([entry.worklog, entry.duration])
+                tasks_per_day[date]['tasks'].append([entry.task, entry.duration])
             else:
-                worklogs_per_day[date]['worklogs'][index][1] += entry.duration
-            worklogs_per_day[date]['time'] += entry.duration
+                tasks_per_day[date]['tasks'][index][1] += entry.duration
+            tasks_per_day[date]['time'] += entry.duration
         else:
-            worklogs_per_day[date] = {
+            tasks_per_day[date] = {
                     'time': entry.duration,
-                    'worklogs': [[entry.worklog, entry.duration]]
+                    'tasks': [[entry.task, entry.duration]]
                 }
 
-        if entry.worklog.project in time_per_project:
-            time_per_project[entry.worklog.project]['time'] += entry.duration
+        if entry.task.project in time_per_project:
+            time_per_project[entry.task.project]['time'] += entry.duration
             try:
-                index = list(map(lambda a: a[0].id, time_per_project[entry.worklog.project]['worklogs'])).index(entry.worklog.id)
+                index = list(map(lambda a: a[0].id, time_per_project[entry.task.project]['tasks'])).index(entry.task.id)
             except ValueError:
-                time_per_project[entry.worklog.project]['worklogs'].append([entry.worklog, entry.duration])
+                time_per_project[entry.task.project]['tasks'].append([entry.task, entry.duration])
             else:
-                time_per_project[entry.worklog.project]['worklogs'][index][1] += entry.duration
+                time_per_project[entry.task.project]['tasks'][index][1] += entry.duration
         else:
-            time_per_project[entry.worklog.project] = {
+            time_per_project[entry.task.project] = {
                     'time': entry.duration,
-                    'worklogs': [[entry.worklog, entry.duration]]
+                    'tasks': [[entry.task, entry.duration]]
                 }
 
     context_vars = {
         'from': from_date.date(),
         'to': to_date.date(),
-        'worklogs_per_day': worklogs_per_day,
+        'tasks_per_day': tasks_per_day,
         'time_per_project': time_per_project,
-        'time_per_worklog': time_per_worklog,
+        'time_per_task': time_per_task,
     }
     return render_to_response('worklogs/report.html', context_vars)