Include the tabimport import utility
This commit is contained in:
parent
2c2b5078f8
commit
e0fd4b42ea
6 changed files with 26 additions and 0 deletions
|
|
@ -117,6 +117,7 @@ INSTALLED_APPS = (
|
|||
'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
'tabimport',
|
||||
'stages',
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ urlpatterns = patterns('',
|
|||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^data-import/', include('tabimport.urls')),
|
||||
|
||||
url(r'^attribution/$', views.AttributionView.as_view(), name='attribution'),
|
||||
url(r'^stages/export/$', 'stages.views.stages_export', name='stages_export'),
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ Django >= 1.4.2
|
|||
south
|
||||
-e git+https://github.com/claudep/tabimport.git#egg=tabimport
|
||||
openpyxl
|
||||
xlrd
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@ from __future__ import unicode_literals
|
|||
from django.db import models
|
||||
|
||||
|
||||
def is_int(s):
|
||||
try:
|
||||
int(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
class Section(models.Model):
|
||||
""" Filières """
|
||||
name = models.CharField(max_length=20)
|
||||
|
|
@ -44,6 +52,19 @@ class Student(models.Model):
|
|||
def __unicode__(self):
|
||||
return '%s %s' % (self.last_name, self.first_name)
|
||||
|
||||
@classmethod
|
||||
def prepare_import(cls, values):
|
||||
''' Hook for tabimport, before new object get created '''
|
||||
if 'klass' in values:
|
||||
try:
|
||||
k = Klass.objects.get(name=values['klass'])
|
||||
except Klass.DoesNotExist:
|
||||
raise Exception("La classe '%s' n'existe pas encore" % values['klass'])
|
||||
values['klass'] = k
|
||||
if 'city' in values and is_int(values['city'][:4]):
|
||||
values['pcode'], _, values['city'] = values['city'].partition(' ')
|
||||
return values
|
||||
|
||||
|
||||
class Referent(models.Model):
|
||||
first_name = models.CharField(max_length=40, verbose_name='Prénom')
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
{% endfor %}
|
||||
<ul>
|
||||
<li><a href="{% url 'attribution' %}">Attributions des stages</a></li>
|
||||
<li><a href="{% url 'tabimport' %}">Importer des données</a></li>
|
||||
<li><a href="{% url 'stages_export' %}">Exporter les données de stages</a></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
|
|
|
|||
1
templates/base.html
Normal file
1
templates/base.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue