-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/regex/work_entries/templates/work_entries/workentry_list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% extends "base.html" %} | ||
|
||
|
||
{% block content %} | ||
<section class="work-item-list"> | ||
<h1 class="work-item-list__title">{{ project.name }}</h1> | ||
{% for entry in work_entries %} | ||
<article class="work-item"> | ||
<span class="work-item__date"><i class="fa fa-calendar-o"></i> {{ entry.start|date:"d-m-y" }}</span> | ||
<span class="work-item__duration"><i class="fa fa-clock-o"></i> {{ entry.duration }}</span> | ||
<span class="work-item__time">{{ entry.start|date:"H:i" }} – {{ entry.end|date:"H:i" }}</span> | ||
<p class="work-item__notes">{{ entry.notes }}</p> | ||
</article> | ||
{% endfor %} | ||
</section> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import url | ||
|
||
from .views import WorkEntryList | ||
|
||
app_name = 'work_entries' | ||
urlpatterns = [ | ||
url(r'^(?P<project_slug>[\w-]+)/log/', WorkEntryList.as_view(), name='list'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.db.models import F | ||
from django.shortcuts import get_object_or_404 | ||
from django.views.generic import ListView | ||
|
||
from regex.crm.models import Project | ||
|
||
from .models import WorkEntry | ||
|
||
|
||
class WorkEntryList(LoginRequiredMixin, ListView): | ||
model = WorkEntry | ||
context_object_name = 'work_entries' | ||
|
||
def _get_project_filters(self): | ||
return { | ||
'slug': self.kwargs['project_slug'], | ||
'client__contacts__user': self.request.user | ||
} | ||
|
||
def get_queryset(self): | ||
qs = super().get_queryset() | ||
filters = {'project__%s' % key: value for key, value in self._get_project_filters().items()} | ||
return qs.filter(**filters).annotate(duration=F('end') - F('start')) | ||
|
||
def get_context_data(self, **kwargs): | ||
qs = Project.objects.filter(**self._get_project_filters()) | ||
kwargs['project'] = get_object_or_404(qs) | ||
return super().get_context_data(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import "login"; | ||
@import "project"; | ||
@import "work-item"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.work-item { | ||
border-top: solid 1px $base-border-color; | ||
padding: 1em 0; | ||
|
||
&__date { | ||
font-weight: 700; | ||
} | ||
|
||
&__duration { | ||
margin-left: 1em; | ||
} | ||
|
||
&__time { | ||
float: right; | ||
} | ||
|
||
&__notes:not(:empty) { | ||
margin-top: .5em; | ||
margin-left: .5em; | ||
padding-left: .5em; | ||
border-left: solid 3px $palette-light; | ||
} | ||
} |