Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Dec 19, 2016
2 parents 5181820 + df43b7a commit b1fbf92
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/regex/accounts/templates/accounts/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2 class="project__title">{{ project.name }}</h2>
{% endif %}
</p>
<p class="project__details">
<a href="#">
<a href="{% url 'work_entries:list' project_slug=project.slug %}">
{% blocktrans with count=project.n_workentries trimmed %}
{{ count }} work entries logged
{% endblocktrans %}</a>
Expand Down
1 change: 1 addition & 0 deletions src/regex/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
url(r'^accounts/', include('regex.accounts.urls', namespace='accounts')),
url(r'^invoices/', include('regex.invoices.urls', namespace='invoices')),
url(r'^portfolio/', include('regex.portfolio.urls', namespace='portfolio')),
url(r'^work_entries/', include('regex.work_entries.urls', namespace='work_entries')),
url(r'^', include('regex.homepage.urls', namespace='home')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT, show_indexes=True)

Expand Down
2 changes: 1 addition & 1 deletion src/regex/work_entries/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def delta_to_decimal(self, round=False):
timedelta = self.end - self.start
delta = relativedelta(seconds=timedelta.total_seconds())

total_minutes = delta.days*24*60 + delta.hours * 60 + delta.minutes + delta.seconds / 60
total_minutes = delta.days * 24 * 60 + delta.hours * 60 + delta.minutes + delta.seconds / 60
if round:
remainder = total_minutes % 15
if remainder > 7.5:
Expand Down
16 changes: 16 additions & 0 deletions src/regex/work_entries/templates/work_entries/workentry_list.html
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" }} &ndash; {{ entry.end|date:"H:i" }}</span>
<p class="work-item__notes">{{ entry.notes }}</p>
</article>
{% endfor %}
</section>
{% endblock content %}
8 changes: 8 additions & 0 deletions src/regex/work_entries/urls.py
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'),
]
29 changes: 29 additions & 0 deletions src/regex/work_entries/views.py
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)
1 change: 1 addition & 0 deletions src/sass/components/_all.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import "login";
@import "project";
@import "work-item";
23 changes: 23 additions & 0 deletions src/sass/components/_work-item.scss
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;
}
}

0 comments on commit b1fbf92

Please sign in to comment.