Browse Source

added member page for hardware provisioning

Damien Nicolas 9 years ago
parent
commit
d183ae5a59

+ 2 - 0
coin/templates/menu_items.html

@@ -3,6 +3,8 @@
 <li class="{% ifactive 'members:detail' %}active{% endifactive %}"><a href="{% url 'members:detail' %}"><i class="fa fa-user fa-fw"></i> Mes informations</a></li>
 <li class="{% ifactive 'members:detail' %}active{% endifactive %}"><a href="{% url 'members:detail' %}"><i class="fa fa-user fa-fw"></i> Mes informations</a></li>
 <li class="{% ifactive 'members:subscriptions' %}active{% endifactive %}"><a href="{% url 'members:subscriptions' %}"><i class="fa fa-cog fa-fw"></i> Mes abonnements</a></li>
 <li class="{% ifactive 'members:subscriptions' %}active{% endifactive %}"><a href="{% url 'members:subscriptions' %}"><i class="fa fa-cog fa-fw"></i> Mes abonnements</a></li>
 <li class="{% ifactive 'members:invoices' %}active{% endifactive %}"><a href="{% url 'members:invoices' %}"><i class="fa fa-eur fa-fw"></i> Factures &amp; paiements</a></li>
 <li class="{% ifactive 'members:invoices' %}active{% endifactive %}"><a href="{% url 'members:invoices' %}"><i class="fa fa-eur fa-fw"></i> Factures &amp; paiements</a></li>
+<li class="{% ifactive 'hardware_provisioning:loan-list' %}active{% endifactive %}"><a href="{% url 'hardware_provisioning:loan-list' %}"><i
+            class="fa fa-exchange fa-fw"></i> Prêts de matériel</a></li>
 <li class="{% ifactive 'members:contact' %}active{% endifactive %}"><a href="{% url 'members:contact' %}"><i class="fa fa-life-ring fa-fw"></i> Contact / Support</a></li>
 <li class="{% ifactive 'members:contact' %}active{% endifactive %}"><a href="{% url 'members:contact' %}"><i class="fa fa-life-ring fa-fw"></i> Contact / Support</a></li>
 <li class="divider"></li>
 <li class="divider"></li>
 {% if user.is_staff %}<li><a href="{% url 'admin:index' %}"><i class="fa fa-cogs fa-fw"></i> Administration</a></li>{% endif %}
 {% if user.is_staff %}<li><a href="{% url 'admin:index' %}"><i class="fa fa-cogs fa-fw"></i> Administration</a></li>{% endif %}

+ 2 - 0
coin/urls.py

@@ -37,6 +37,8 @@ urlpatterns = patterns(
     url(r'^members/', include('coin.members.urls', namespace='members')),
     url(r'^members/', include('coin.members.urls', namespace='members')),
     url(r'^billing/', include('coin.billing.urls', namespace='billing')),
     url(r'^billing/', include('coin.billing.urls', namespace='billing')),
     url(r'^subscription/', include('coin.offers.urls', namespace='subscription')),
     url(r'^subscription/', include('coin.offers.urls', namespace='subscription')),
+    url(r'^hardware-provisioning/', include('hardware_provisioning.urls',
+        namespace='hardware_provisioning')),
 
 
     url(r'^admin/', include(admin.site.urls)),
     url(r'^admin/', include(admin.site.urls)),
 
 

+ 32 - 0
hardware_provisioning/migrations/0002_auto_20150625_2313.py

@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('hardware_provisioning', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='item',
+            name='buy_date',
+            field=models.DateField(verbose_name='date d\u2019achat'),
+            preserve_default=True,
+        ),
+        migrations.AlterField(
+            model_name='loan',
+            name='loan_date',
+            field=models.DateField(verbose_name='date de pr\xeat'),
+            preserve_default=True,
+        ),
+        migrations.AlterField(
+            model_name='loan',
+            name='loan_date_end',
+            field=models.DateField(null=True, verbose_name='date de fin de pr\xeat', blank=True),
+            preserve_default=True,
+        ),
+    ]

+ 4 - 4
hardware_provisioning/models.py

@@ -23,7 +23,7 @@ class Item(models.Model):
     designation = models.CharField(max_length=100, verbose_name='désignation')
     designation = models.CharField(max_length=100, verbose_name='désignation')
     mac_address = MACAddressField(verbose_name='addresse MAC', blank=True,
     mac_address = MACAddressField(verbose_name='addresse MAC', blank=True,
                                   null=True)
                                   null=True)
-    buy_date = models.DateTimeField(verbose_name='date d’achat')
+    buy_date = models.DateField(verbose_name='date d’achat')
     user_in_charge = models.ForeignKey(settings.AUTH_USER_MODEL,
     user_in_charge = models.ForeignKey(settings.AUTH_USER_MODEL,
                                        verbose_name='membre responsable',
                                        verbose_name='membre responsable',
                                        related_name='items')
                                        related_name='items')
@@ -61,9 +61,9 @@ class Loan(models.Model):
     item = models.ForeignKey(Item, verbose_name='objet', related_name='loans')
     item = models.ForeignKey(Item, verbose_name='objet', related_name='loans')
     user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='membre',
     user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='membre',
                              related_name='loans')
                              related_name='loans')
-    loan_date = models.DateTimeField(verbose_name='date de prêt')
-    loan_date_end = models.DateTimeField(verbose_name='date de fin de prêt',
-                                         null=True, blank=True)
+    loan_date = models.DateField(verbose_name='date de prêt')
+    loan_date_end = models.DateField(verbose_name='date de fin de prêt',
+                                     null=True, blank=True)
     location = models.CharField(max_length=100, verbose_name='emplacement',
     location = models.CharField(max_length=100, verbose_name='emplacement',
                                 null=True, blank=True)
                                 null=True, blank=True)
 
 

+ 26 - 0
hardware_provisioning/templates/hardware_provisioning/list.html

@@ -0,0 +1,26 @@
+{% extends "base.html" %}
+
+{% block content %}
+<h2>Mes prêts</h2>
+
+<table id="member_loans" class="full-width">
+    <thead>
+        <tr>
+            <th>Type de matériel</th>
+            <th>Matériel prêté</th>
+            <th>Date de prêt</th>
+        </tr>
+    </thead>
+    <tbody>
+        {% for loan in loans %}
+        <tr>
+            <td>{{ loan.item.type }}</td>
+            <td>{{ loan.item }}</a></td>
+            <td>{{ loan.loan_date }}</td>
+        </tr>
+        {% endfor %}
+    </tbody>
+</table>
+
+{% endblock %}
+

+ 11 - 0
hardware_provisioning/urls.py

@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+from django.conf.urls import url
+from . import views
+
+
+urlpatterns = [
+    url(r'^$', views.loan_list, name='loan-list'),
+    url(r'^(?P<pk>[0-9]+)$', views.loan_detail, name='loan-detail'),
+]

+ 15 - 1
hardware_provisioning/views.py

@@ -1,3 +1,17 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
 from django.shortcuts import render
 from django.shortcuts import render
+from django.contrib.auth.decorators import login_required
+from .models import Item, Loan
+
+
+@login_required
+def loan_list(request):
+    loans = request.user.loans.all()
+    return render(request, 'hardware_provisioning/list.html', {'loans': loans})
+
 
 
-# Create your views here.
+@login_required
+def loan_detail(request, pk):
+    return render(request, 'hardware_provisioning/detail.html', {})