diff --git a/logs/__pycache__/__init__.cpython-34.pyc b/logs/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..eff4daee
Binary files /dev/null and b/logs/__pycache__/__init__.cpython-34.pyc differ
diff --git a/logs/__pycache__/admin.cpython-34.pyc b/logs/__pycache__/admin.cpython-34.pyc
new file mode 100644
index 00000000..d6cde33c
Binary files /dev/null and b/logs/__pycache__/admin.cpython-34.pyc differ
diff --git a/logs/__pycache__/models.cpython-34.pyc b/logs/__pycache__/models.cpython-34.pyc
new file mode 100644
index 00000000..9e475a66
Binary files /dev/null and b/logs/__pycache__/models.cpython-34.pyc differ
diff --git a/logs/__pycache__/views.cpython-34.pyc b/logs/__pycache__/views.cpython-34.pyc
new file mode 100644
index 00000000..4e136851
Binary files /dev/null and b/logs/__pycache__/views.cpython-34.pyc differ
diff --git a/logs/migrations/__pycache__/__init__.cpython-34.pyc b/logs/migrations/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..8d80982f
Binary files /dev/null and b/logs/migrations/__pycache__/__init__.cpython-34.pyc differ
diff --git a/machines/__init__.py b/machines/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/machines/__pycache__/__init__.cpython-34.pyc b/machines/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..9cf00c57
Binary files /dev/null and b/machines/__pycache__/__init__.cpython-34.pyc differ
diff --git a/machines/__pycache__/admin.cpython-34.pyc b/machines/__pycache__/admin.cpython-34.pyc
new file mode 100644
index 00000000..737c879e
Binary files /dev/null and b/machines/__pycache__/admin.cpython-34.pyc differ
diff --git a/machines/__pycache__/models.cpython-34.pyc b/machines/__pycache__/models.cpython-34.pyc
new file mode 100644
index 00000000..8529d171
Binary files /dev/null and b/machines/__pycache__/models.cpython-34.pyc differ
diff --git a/machines/admin.py b/machines/admin.py
new file mode 100644
index 00000000..83317546
--- /dev/null
+++ b/machines/admin.py
@@ -0,0 +1,12 @@
+from django.contrib import admin
+
+from .models import Machine, MachineType
+
+class MachineAdmin(admin.ModelAdmin):
+ list_display = ('user','type')
+
+class MachineTypeAdmin(admin.ModelAdmin):
+ list_display = ('type',)
+
+admin.site.register(Machine, MachineAdmin)
+admin.site.register(MachineType, MachineTypeAdmin)
diff --git a/machines/migrations/0001_initial.py b/machines/migrations/0001_initial.py
new file mode 100644
index 00000000..9116d76b
--- /dev/null
+++ b/machines/migrations/0001_initial.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0005_auto_20160702_0006'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Machine',
+ fields=[
+ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='MachineType',
+ fields=[
+ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+ ('type', models.CharField(max_length=255)),
+ ],
+ ),
+ migrations.AddField(
+ model_name='machine',
+ name='type',
+ field=models.ForeignKey(to='machines.MachineType', on_delete=django.db.models.deletion.PROTECT),
+ ),
+ migrations.AddField(
+ model_name='machine',
+ name='user',
+ field=models.ForeignKey(to='users.User', on_delete=django.db.models.deletion.PROTECT),
+ ),
+ ]
diff --git a/machines/migrations/__init__.py b/machines/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/machines/migrations/__pycache__/0001_initial.cpython-34.pyc b/machines/migrations/__pycache__/0001_initial.cpython-34.pyc
new file mode 100644
index 00000000..f67ebf81
Binary files /dev/null and b/machines/migrations/__pycache__/0001_initial.cpython-34.pyc differ
diff --git a/machines/migrations/__pycache__/__init__.cpython-34.pyc b/machines/migrations/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..42cd9a8d
Binary files /dev/null and b/machines/migrations/__pycache__/__init__.cpython-34.pyc differ
diff --git a/machines/models.py b/machines/models.py
new file mode 100644
index 00000000..d93324dd
--- /dev/null
+++ b/machines/models.py
@@ -0,0 +1,16 @@
+from django.db import models
+
+from users.models import User
+
+class Machine(models.Model):
+ user = models.ForeignKey('users.User', on_delete=models.PROTECT)
+ type = models.ForeignKey('MachineType', on_delete=models.PROTECT)
+
+ def __str__(self):
+ return self.type
+
+class MachineType(models.Model):
+ type = models.CharField(max_length=255)
+
+ def __str__(self):
+ return self.type
diff --git a/machines/tests.py b/machines/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/machines/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/machines/views.py b/machines/views.py
new file mode 100644
index 00000000..91ea44a2
--- /dev/null
+++ b/machines/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/re2o/__pycache__/__init__.cpython-34.pyc b/re2o/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..9a7ffeed
Binary files /dev/null and b/re2o/__pycache__/__init__.cpython-34.pyc differ
diff --git a/re2o/__pycache__/login.cpython-34.pyc b/re2o/__pycache__/login.cpython-34.pyc
new file mode 100644
index 00000000..74cf5a88
Binary files /dev/null and b/re2o/__pycache__/login.cpython-34.pyc differ
diff --git a/re2o/__pycache__/urls.cpython-34.pyc b/re2o/__pycache__/urls.cpython-34.pyc
new file mode 100644
index 00000000..680db1d5
Binary files /dev/null and b/re2o/__pycache__/urls.cpython-34.pyc differ
diff --git a/re2o/__pycache__/wsgi.cpython-34.pyc b/re2o/__pycache__/wsgi.cpython-34.pyc
new file mode 100644
index 00000000..2c119761
Binary files /dev/null and b/re2o/__pycache__/wsgi.cpython-34.pyc differ
diff --git a/search/__init__.py b/search/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/search/__pycache__/__init__.cpython-34.pyc b/search/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..bfaea68a
Binary files /dev/null and b/search/__pycache__/__init__.cpython-34.pyc differ
diff --git a/search/__pycache__/admin.cpython-34.pyc b/search/__pycache__/admin.cpython-34.pyc
new file mode 100644
index 00000000..777989f9
Binary files /dev/null and b/search/__pycache__/admin.cpython-34.pyc differ
diff --git a/search/__pycache__/models.cpython-34.pyc b/search/__pycache__/models.cpython-34.pyc
new file mode 100644
index 00000000..a3d7cea6
Binary files /dev/null and b/search/__pycache__/models.cpython-34.pyc differ
diff --git a/search/__pycache__/urls.cpython-34.pyc b/search/__pycache__/urls.cpython-34.pyc
new file mode 100644
index 00000000..b0edb38a
Binary files /dev/null and b/search/__pycache__/urls.cpython-34.pyc differ
diff --git a/search/__pycache__/views.cpython-34.pyc b/search/__pycache__/views.cpython-34.pyc
new file mode 100644
index 00000000..9d6cc725
Binary files /dev/null and b/search/__pycache__/views.cpython-34.pyc differ
diff --git a/search/admin.py b/search/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/search/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/search/forms.py b/search/forms.py
new file mode 100644
index 00000000..499e99fc
--- /dev/null
+++ b/search/forms.py
@@ -0,0 +1,16 @@
+from django.db.models import Q
+from simple_search import BaseSearchForm
+
+from users.models import User, School
+
+class UserSearchForm(BaseSearchForm):
+ class Meta:
+ base_qs = User.objects
+ search_fields = ('^name', 'description', 'specifications', '=id')
+
+ # assumes a fulltext index has been defined on the fields
+ # 'name,description,specifications,id'
+ fulltext_indexes = (
+ ('name', 2), # name matches are weighted higher
+ ('name,description,specifications,id', 1),
+ )
diff --git a/search/migrations/__init__.py b/search/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/search/migrations/__pycache__/__init__.cpython-34.pyc b/search/migrations/__pycache__/__init__.cpython-34.pyc
new file mode 100644
index 00000000..433a3221
Binary files /dev/null and b/search/migrations/__pycache__/__init__.cpython-34.pyc differ
diff --git a/search/models.py b/search/models.py
new file mode 100644
index 00000000..fee5f7ef
--- /dev/null
+++ b/search/models.py
@@ -0,0 +1,10 @@
+from django.db import models
+from django import forms
+from django.forms import Form
+from django.forms import ModelForm
+
+from users.models import User
+# Create your models here.
+
+class SearchForm(Form):
+ search_field = forms.CharField(label = 'Search', max_length = 100)
diff --git a/search/templates/search/index.html b/search/templates/search/index.html
new file mode 100644
index 00000000..bf02d7c8
--- /dev/null
+++ b/search/templates/search/index.html
@@ -0,0 +1,90 @@
+{% extends "users/sidebar.html" %}
+{% load bootstrap3 %}
+
+{% block title %}Utilisateurs{% endblock %}
+
+{% block content %}
+ {% if users_list %}
+
Résultats dans les utilisateurs
+
+
+
+ Prénom |
+ Nom |
+ Pseudo |
+ Modifier |
+
+
+ {% for user in users_list %}
+
+ {{ user.name }} |
+ {{ user.surname }} |
+ {{ user.pseudo }} |
+ Editer |
+
+ {% endfor %}
+
+ {% endif%}
+ {% if machine_list %}
+ Résultats dans les machines :
+
+
+
+ Nom |
+
+
+ {% for machine in machine_list %}
+
+ {{ machine.name }} |
+
+ {% endfor %}
+
+ {% endif %}
+ {% if facture_list %}
+ Résultats dans les factures :
+
+
+
+ Utilisateur |
+ Designation |
+ Nombre |
+ Prix unitaire |
+ Moyen de paiement |
+ Date |
+
+
+ {% for facture in facture_list %}
+
+ {{ facture.user }} |
+ {{ facture.name }} |
+ {{ facture.number }} |
+ {{ facture.prix }} |
+ {{ facture.paiement }} |
+ {{ facture.date }} |
+
+ {% endfor %}
+
+ {% endif %}
+ {% if ban_list %}
+ Résultats dans les banissements :
+
+
+
+ Utilisateur |
+ Raison |
+ Date de début |
+ Date de fin |
+
+
+ {% for ban in ban_list %}
+
+ {{ ban.user }} |
+ {{ ban.raison }} |
+ {{ ban.date_start }} |
+ {{ ban.date_end }} |
+
+ {% endfor %}
+
+ {% endif %}
+{% endblock %}
+
diff --git a/search/templates/search/search.html b/search/templates/search/search.html
new file mode 100644
index 00000000..063ee55d
--- /dev/null
+++ b/search/templates/search/search.html
@@ -0,0 +1,14 @@
+{% extends "search/sidebar.html" %}
+{% load bootstrap3 %}
+
+{% block title %}Création et modification d'utilisateur{% endblock %}
+
+{% block content %}
+{% bootstrap_form_errors searchform %}
+
+
+{% endblock %}
diff --git a/search/templates/search/sidebar.html b/search/templates/search/sidebar.html
new file mode 100644
index 00000000..debd89e3
--- /dev/null
+++ b/search/templates/search/sidebar.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block sidebar %}
+ Créer un adhérent
+ Editer un adhérent
+ Liste des adhérents
+ Ajouter un droit rezo
+ Retirer un droit rezo
+{% endblock %}
diff --git a/search/tests.py b/search/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/search/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/search/urls.py b/search/urls.py
new file mode 100644
index 00000000..cb1247b4
--- /dev/null
+++ b/search/urls.py
@@ -0,0 +1,7 @@
+from django.conf.urls import url
+
+from . import views
+
+urlpatterns = [
+ url(r'^$', views.search, name='search'),
+]
diff --git a/search/views.py b/search/views.py
new file mode 100644
index 00000000..d27c4614
--- /dev/null
+++ b/search/views.py
@@ -0,0 +1,34 @@
+# App de recherche pour re2o
+# Gabriel Détraz, Goulven Kermarec
+# Gplv2
+from django.shortcuts import render
+from django.shortcuts import render_to_response, get_object_or_404
+from django.core.context_processors import csrf
+from django.template import Context, RequestContext, loader
+
+from django.db.models import Q
+from users.models import User, Ban
+from machines.models import Machine
+from cotisations.models import Facture
+from search.models import SearchForm
+
+def form(ctx, template, request):
+ c = ctx
+ c.update(csrf(request))
+ return render_to_response(template, c, context_instance=RequestContext(request))
+
+def search(request):
+ if request.method == 'POST':
+ search = SearchForm(request.POST or None)
+ if search.is_valid():
+ search = search.cleaned_data['search_field']
+ users = User.objects.filter(Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search))
+ machines = None
+ query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search)
+ factures = Facture.objects.filter(query)
+ bans = Ban.objects.filter(query)
+ return form({'users_list': users, 'machine_list' : machines, 'facture_list' : factures, 'ban_list' : bans}, 'search/index.html',request)
+ return form({'searchform' : search}, 'search/search.html', request)
+ else:
+ search = SearchForm(request.POST or None)
+ return form({'searchform': search}, 'search/search.html',request)