]> git.parisson.com Git - mezzo.git/commitdiff
[Timesheet] : user dashboard + create form
authorEmilie <zawadzki@ircam.fr>
Thu, 29 Dec 2016 17:24:23 +0000 (18:24 +0100)
committerEmilie <zawadzki@ircam.fr>
Thu, 29 Dec 2016 17:24:23 +0000 (18:24 +0100)
app/organization/network/admin.py
app/organization/network/forms.py
app/organization/network/urls.py
app/organization/network/views.py
app/templates/network/person_activity_timesheet/includes/person_activity_timesheet_inline.html [new file with mode: 0644]
app/templates/network/person_activity_timesheet/person_activity_timesheet_create.html [new file with mode: 0644]
app/templates/network/person_activity_timesheet/person_activity_timesheet_list.html [new file with mode: 0644]

index 87ecff89651d50bd7ce9b81efeb853af2b7f5225..b815fd91dd13c80acea9e39d6a7bb2ee2e5f16b2 100644 (file)
@@ -150,7 +150,16 @@ class PersonActivityInline(StackedDynamicInlineAdmin):
     fk_name = 'person'
     filter_horizontal = ['organizations', 'employers', 'teams',
                          'projects', 'supervisors', 'phd_directors', ]
-
+    # fields = ()
+    #
+    # fields = (('monday_am','monday_pm'), 'weekly_hour_volume')
+
+    # def __init__(self, *args, **kwargs):
+    #     super(PersonActivityInline, self).__init__(*args, **kwargs)
+    #     # print(self.model._meta.get_fields())
+    #     self.fields = self.model._meta.get_fields()
+    #     print(self.fields)
+    #     # self.fields.append(('monday_am', 'monday_pm'))
 
 class PersonPlaylistInline(TabularDynamicInlineAdmin):
 
index db8eef8c2f20a3b7d996acc23f68ecb54771a33d..6bdd504305f04cc6928697e3160900a964710189 100644 (file)
@@ -33,7 +33,8 @@ from organization.network.models import (Person,
                                 OrganizationLinked,
                                 OrganizationLinkedInline,
                                 OrganizationLinkedBlockInline,
-                                Organization)
+                                Organization,
+                                PersonActivityTimeSheet)
 from organization.pages.models import Page, CustomPage
 
 
@@ -83,3 +84,11 @@ class OrganizationLinkedForm(forms.ModelForm):
     class Meta:
         model = OrganizationLinkedInline
         fields = ('organization',)
+
+
+class PersonActivityTimeSheetForm(forms.ModelForm):
+
+    class Meta:
+        model = PersonActivityTimeSheet
+        fields = ('__all__')
+        # PersonActivityTimeSheetviewfields = ['pub_date', 'headline', 'content', 'reporter']
index a0a5823f5d0526955539f611762fc3aff8e0bc4f..e139349f19b2743e7f9f811631e672eb0c8a847e 100644 (file)
@@ -31,11 +31,12 @@ from mezzanine.conf import settings
 from organization.network.views import *
 
 urlpatterns = [
+    url(r'^person/(?P<slug>.*)/timesheet/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/create/$', TimeSheetCreateView.as_view(), name="organization-network-timesheet-create-view"),
+    url(r'^person/(?P<slug>.*)/timesheet/dashboard/$', PersonActivityTimeSheetListView.as_view(), name="organization-network-timesheet-list-view" ),
     url(r'^person/(?P<slug>.*)/$', PersonDetailView.as_view(), name="organization-network-person-detail"),
     url("^person-list-block-autocomplete/$", permission_required('person.can_edit')(PersonListBlockAutocompleteView.as_view()), name='person-list-block-autocomplete'),
     url("^person-autocomplete/$", permission_required('person.can_edit')(PersonListView.as_view()), name='person-autocomplete'),
     url("^network/$", OrganizationListView.as_view(), name='network'),
     url("^organization-linked-list-autocomplete/$",  permission_required('organization.can_edit')(OrganizationLinkedListView.as_view()), name='organization-linked-list-autocomplete'),
     url("^organization-linked-autocomplete/$",  permission_required('organization.can_edit')(OrganizationLinkedView.as_view()), name='organization-linked-autocomplete'),
-
     ]
index 0c6d166ba8eaba59a069e48ca7daa423b80c74f9..c91c2947bf3e7208eaf8d31725874365fb81e8cd 100644 (file)
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 from django.shortcuts import render
+from django.views.generic.edit import CreateView
 from dal import autocomplete
 from organization.network.models import *
 from organization.core.views import *
-
+from datetime import date
+from organization.network.forms import *
 
 class PersonListView(ListView):
 
@@ -115,3 +117,39 @@ class OrganizationLinkedView(autocomplete.Select2QuerySetView):
         if self.q:
             qs = qs.filter(name__istartswith=self.q)
         return qs
+
+
+class TimeSheetCreateView(CreateView):
+    model = PersonActivityTimeSheet
+    template_name='network/person_activity_timesheet/person_activity_timesheet_create.html'
+    context_object_name = 'timesheet'
+    form_class = PersonActivityTimeSheetForm
+
+    def get_initial(self):
+        initial = super(TimeSheetCreateView, self).get_initial()
+        initial['activity'] = PersonActivity.objects.filter(person__slug=self.kwargs['slug']).first()
+        initial['month'] = self.kwargs['month']
+        initial['year'] = self.kwargs['year']
+        return initial
+
+    def get_context_data(self, **kwargs):
+        context = super(TimeSheetCreateView, self).get_context_data(**kwargs)
+        context.update(self.kwargs)
+        return context
+
+
+class PersonActivityTimeSheetListView(ListView):
+    model = PersonActivityTimeSheet
+    template_name='network/person_activity_timesheet/person_activity_timesheet_list.html'
+    context_object_name = 'timesheet'
+
+    def get_queryset(self):
+        if 'slug' in self.kwargs:
+            return PersonActivityTimeSheet.objects.filter(activity__person__slug__exact=self.kwargs['slug'])
+
+    def get_context_data(self, **kwargs):
+        context = super(PersonActivityTimeSheetListView, self).get_context_data(**kwargs)
+        context['current_month'] = date.today().month
+        context['current_year'] = date.today().year
+        context.update(self.kwargs)
+        return context
diff --git a/app/templates/network/person_activity_timesheet/includes/person_activity_timesheet_inline.html b/app/templates/network/person_activity_timesheet/includes/person_activity_timesheet_inline.html
new file mode 100644 (file)
index 0000000..3cbd38c
--- /dev/null
@@ -0,0 +1 @@
+{{ object }}
diff --git a/app/templates/network/person_activity_timesheet/person_activity_timesheet_create.html b/app/templates/network/person_activity_timesheet/person_activity_timesheet_create.html
new file mode 100644 (file)
index 0000000..1b9cd62
--- /dev/null
@@ -0,0 +1,25 @@
+{% extends "pages/page.html" %}
+{% load i18n mezzanine_tags keyword_tags pages_tags organization_tags %}
+
+{% block meta_title %}{% trans "Timesheet" %}{% endblock %}
+
+{% block page_class %}
+    time_sheet
+{% endblock %}
+
+{% block page_title %}
+  <h1 class="dotted">{% trans "Timesheet" %}</h1>
+{% endblock %}
+
+{% block page_content %}
+
+    <a class="pull-right button button--black" href="{% url 'organization-network-timesheet-list-view' slug %}" title="">Back to dashboard</a>
+
+    <form class="form" action="" method="post">
+        {% csrf_token %}
+        {{ form.as_p }}
+        <input type="submit" value="Submit" />
+    </form>
+
+
+{% endblock %}
diff --git a/app/templates/network/person_activity_timesheet/person_activity_timesheet_list.html b/app/templates/network/person_activity_timesheet/person_activity_timesheet_list.html
new file mode 100644 (file)
index 0000000..30a2295
--- /dev/null
@@ -0,0 +1,30 @@
+{% extends "pages/page.html" %}
+{% load i18n mezzanine_tags keyword_tags pages_tags organization_tags %}
+
+{% block meta_title %}{% trans "Timesheet" %}{% endblock %}
+
+{% block page_class %}
+    time_sheet
+{% endblock %}
+
+{% block page_title %}
+  <h1 class="dotted">{% trans "Timesheet" %}</h1>
+{% endblock %}
+
+{% block page_content %}
+
+    <a class="pull-right button button--black" href="{% url 'organization-network-timesheet-create-view' slug current_year current_month %}" title="">Declare this month</a>
+
+    {% if person_activity_timesheet %}
+
+        {% for pat in person_activity_timesheet %}
+            {% include "network/person_activity_timesheet/includes/person_activity_timesheet_inline.html" with object=pat %}
+        {% endfor %}
+
+    {% else %}
+
+        <p>{% trans "No timesheet." %}</p>
+
+    {% endif %}
+
+{% endblock %}