diff --git a/.gitignore b/.gitignore
index 9a7f560..e5ee446 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ db.eds
db.*
*.sql
scripts/*
-
+.idea/*
diff --git a/.idea/eds.iml b/.idea/eds.iml
new file mode 100644
index 0000000..4682891
--- /dev/null
+++ b/.idea/eds.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..6538501
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ca01fa5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..298819b
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,644 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1531759633264
+
+
+ 1531759633264
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/intranet/__init__.py b/intranet/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/intranet/admin.py b/intranet/admin.py
new file mode 100644
index 0000000..392d3bc
--- /dev/null
+++ b/intranet/admin.py
@@ -0,0 +1,32 @@
+
+import os
+
+from django.conf import settings
+from django.contrib import admin
+
+from intranet.models import IntranetDoc
+
+# Register your models here.
+
+
+class IntranetDocAdmin(admin.ModelAdmin):
+
+ list_display = ('__str__', 'module', 'authorization')
+
+ def save_model(self, request, obj, form, change):
+ searched_file = 'intranet/{0}'.format(form.cleaned_data['doc'])
+ try:
+ doc = IntranetDoc.objects.get(doc=searched_file)
+ form.save()
+ # Override previous file
+ filename = os.path.join(settings.MEDIA_ROOT, searched_file)
+ file = request.FILES['doc']
+ with open(filename, 'wb+') as destination:
+ for chunk in file.chunks():
+ destination.write(chunk)
+
+ except IntranetDoc.DoesNotExist:
+ super(IntranetDocAdmin, self).save_model(request, obj, form, change)
+
+
+admin.site.register(IntranetDoc, IntranetDocAdmin)
\ No newline at end of file
diff --git a/intranet/apps.py b/intranet/apps.py
new file mode 100644
index 0000000..9f0e0e3
--- /dev/null
+++ b/intranet/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class IntranetConfig(AppConfig):
+ name = 'intranet'
diff --git a/intranet/migrations/__init__.py b/intranet/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/intranet/models.py b/intranet/models.py
new file mode 100644
index 0000000..260dcf0
--- /dev/null
+++ b/intranet/models.py
@@ -0,0 +1,36 @@
+from django.contrib.auth.models import User
+from django.db import models
+from django.db.models.signals import pre_delete
+from django.dispatch import receiver
+
+from cms.models import Module
+# Create your models here.
+
+
+class IntranetDoc(models.Model):
+ AUTHORIZATION_CHOICES = {
+ (0, 'aucun'),
+ (1, 'étudiant'),
+ (2, 'prof'),
+ (3, 'admin')
+ }
+
+ doc = models.FileField(upload_to='intranet', unique=True)
+ module = models.ForeignKey(Module, null=False, on_delete=models.PROTECT)
+ published = models.BooleanField(default=True, blank=False)
+ authorization = models.SmallIntegerField("autorisation", choices=AUTHORIZATION_CHOICES, default=0)
+
+ class Meta:
+ verbose_name = 'Intranet'
+ verbose_name_plural = 'Intranet'
+
+ def __str__(self):
+ return self.doc.name
+
+
+@receiver(pre_delete, sender=IntranetDoc)
+def remove_file(**kwargs):
+ instance = kwargs.get('instance')
+ instance.doc.delete(save=False)
+
+
diff --git a/intranet/tests.py b/intranet/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/intranet/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/templates/registration/login.html b/templates/registration/login.html
new file mode 100644
index 0000000..397eadf
--- /dev/null
+++ b/templates/registration/login.html
@@ -0,0 +1,66 @@
+{% extends "admin/base_site.html" %}
+{% load i18n static %}
+
+{% block extrastyle %}{{ block.super }}
+{{ form.media }}
+{% endblock %}
+
+{% block bodyclass %}{{ block.super }} login{% endblock %}
+
+{% block usertools %}{% endblock %}
+
+{% block nav-global %}{% endblock %}
+
+{% block content_title %}{% endblock %}
+
+{% block breadcrumbs %}{% endblock %}
+
+{% block content %}
+{% if form.errors and not form.non_field_errors %}
+
+{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
+
+{% endif %}
+
+{% if form.non_field_errors %}
+{% for error in form.non_field_errors %}
+
+ {{ error }}
+
+{% endfor %}
+{% endif %}
+
+
+
+{% if user.is_authenticated %}
+
+{% blocktrans trimmed %}
+ You are authenticated as {{ username }}, but are not authorized to
+ access this page. Would you like to login to a different account?
+{% endblocktrans %}
+
+{% endif %}
+
+
+
+
+{% endblock %}