--- /dev/null
+Droit_administratif
+Droit_des_obligations
+Droit_commercial_des_affaires
+Droit_communautaire_et_européen
+Droit_de_la_famille_et_des_personnes
+Droit_du_travail
+Droit_fiscal
+Droit_international_privé
+Droit_patrimonial
+Droit_public_des_activités_économiques
+Droit_pénal
+Droit_Libertés_publiques
+Note_de_synthèse
+Procédure_administrative_et_contentieuse
+Procédure_civile
+Procédures_collectives_et_sûretés
+Procédure_pénale
+Oral-Procédures_communautaires
+Oral-Voies_d'ex
+Oral-Comptabilité_privée
+Oral-Finances_publiques
+Conférence-actualisation-septembre
print 'exported: ' + user.first_name + ' ' + user.last_name + ' ' + user.username
- def handle(self, *args, **options):
- file = args[0]
+ def export(self):
self.book = Workbook()
self.sheet = self.book.add_sheet('Etudiants')
users = User.objects.all()
row.write(12, 'VILLE')
row.write(13, 'TEL')
row.write(14, "Date d'inscription")
- row.write(15, unicode("Categorie"))
+ row.write(15, "Categorie")
count = self.first_row
for user in users:
self.export_user(count, user)
count += 1
- self.book.save(file)
+
+ self.book.save(self.file)
+
+ def handle(self, *args, **options):
+ self.file = args[0]
+ self.export()
+
+
import jqchat.views
htdocs_forma = os.path.dirname(__file__) + '/htdocs'
+user_export = UsersXLSExport()
urlpatterns = patterns('',
# Users
url(r'^all_users/$', UsersView.as_view(), name="teleforma-users"),
url(r'^all_users/by_trainings/(\w+)$', UsersTrainingView.as_view(), name="teleforma-training-users"),
+ url(r'^all_users/export/$', user_export.export, name="teleforma-users-xls-export"),
# CSS+Images (FIXME: for developement only)
url(r'^teleforma/css/(?P<path>.*)$', 'django.views.static.serve',
from teleforma.models import *
from telemeta.views.base import *
from jqchat.models import *
+from xlwt import Workbook
trainings = Training.objects.filter(id=self.args[0])
return User.objects.filter(student__training__in=trainings)
+class UsersXLSExport(object):
+
+ first_row = 1
+ admin_email = 'webmaster@parisson.com'
+
+ def export_user(self, count, user):
+ student = Student.objects.filter(user=user)
+ if student:
+ student = Student.objects.get(user=user)
+ row = self.sheet.row(count)
+ row.write(0, user.last_name)
+ row.write(1, user.first_name)
+ row.write(9, user.email)
+ row.write(2, unicode(student.iej))
+ row.write(3, unicode(student.training.code))
+ row.write(4, unicode(student.procedure))
+ row.write(5, unicode(student.written_speciality))
+ row.write(6, unicode(student.oral_speciality))
+ row.write(7, unicode(student.oral_1))
+ row.write(8, unicode(student.oral_2))
+ row.write(15, unicode(student.category))
+
+ profile = Profile.objects.filter(user=user)
+ if profile:
+ profile = Profile.objects.get(user=user)
+ row.write(10, profile.address)
+ row.write(11, profile.postal_code)
+ row.write(12, profile.city)
+ row.write(13, profile.telephone)
+ row.write(14, profile.date_added.strftime("%d/%m/%Y"))
+
+ print 'exported: ' + user.first_name + ' ' + user.last_name + ' ' + user.username
+
+ def export(self, request):
+ self.book = Workbook()
+ self.sheet = self.book.add_sheet('Etudiants')
+ users = User.objects.all()
+ row = self.sheet.row(0)
+ row.write(0, 'NOM')
+ row.write(1, 'PRENOM')
+ row.write(2, 'IEJ')
+ row.write(3, 'FORMATION')
+ row.write(4, 'PROC')
+ row.write(5, 'Ecrit Spe')
+ row.write(6, unicode('Oral Spe'))
+ row.write(7, 'ORAL 1')
+ row.write(8, 'ORAL 2')
+ row.write(9, 'MAIL')
+ row.write(10, 'ADRESSE')
+ row.write(11, 'CP')
+ row.write(12, 'VILLE')
+ row.write(13, 'TEL')
+ row.write(14, "Date d'inscription")
+ row.write(15, "Categorie")
+
+ count = self.first_row
+ for user in users:
+ self.export_user(count, user)
+ count += 1
+
+ response = HttpResponse(mimetype="application/vnd.ms-excel")
+ response['Content-Disposition'] = 'attachment; filename=users.xls'
+ self.book.save(response)
+ return response