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):
OrganizationLinked,
OrganizationLinkedInline,
OrganizationLinkedBlockInline,
- Organization)
+ Organization,
+ PersonActivityTimeSheet)
from organization.pages.models import Page, CustomPage
class Meta:
model = OrganizationLinkedInline
fields = ('organization',)
+
+
+class PersonActivityTimeSheetForm(forms.ModelForm):
+
+ class Meta:
+ model = PersonActivityTimeSheet
+ fields = ('__all__')
+ # PersonActivityTimeSheetviewfields = ['pub_date', 'headline', 'content', 'reporter']
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'),
-
]
# 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):
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
--- /dev/null
+{{ object }}
--- /dev/null
+{% 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 %}
--- /dev/null
+{% 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 %}