Le repo des sources pour le site web des JM2L
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

67 lines
2.0 KiB

  1. # -*- coding: utf8 -*-
  2. import os
  3. import sys
  4. import transaction
  5. import time
  6. import lxml.etree as ET
  7. from sqlalchemy import engine_from_config
  8. from sqlalchemy import create_engine
  9. import unicodedata
  10. import urllib
  11. # Usefull tools
  12. from slugify import slugify
  13. from sqlite3 import dbapi2 as sqlite
  14. from os import path
  15. from pyramid.paster import (
  16. get_appsettings,
  17. setup_logging,
  18. )
  19. from jm2l.models import *
  20. from datetime import datetime
  21. def usage(argv):
  22. cmd = os.path.basename(argv[0])
  23. print('usage: %s <config_uri>\n'
  24. '(example: "%s development.ini")' % (cmd, cmd))
  25. sys.exit(1)
  26. def main(argv=sys.argv):
  27. if len(argv) != 2:
  28. usage(argv)
  29. config_uri = argv[1]
  30. setup_logging(config_uri)
  31. settings = get_appsettings(config_uri)
  32. engine = engine_from_config(settings, 'sqlalchemy.')
  33. DBSession.configure(bind=engine)
  34. Base.metadata.create_all(engine)
  35. with transaction.manager:
  36. admin = User(nom=u'jm2l', prenom='contact',
  37. slug='contact jm2l', password=u'jm2l',
  38. mail=u'contact@jm2l.linux-azur.org',
  39. Staff=1
  40. )
  41. DBSession.add(admin)
  42. # Create 2015 year event
  43. jm2l = JM2L_Year(year_uid=2015,
  44. state="Ongoing",
  45. description=u"%d, %dème édition des JM2L." % ( 2015, 9 ),
  46. start_time=datetime.strptime("28-11-2015 10:00","%d-%m-%Y %H:%M"),
  47. end_time=datetime.strptime("28-11-2015 19:00","%d-%m-%Y %H:%M")
  48. )
  49. DBSession.add(jm2l)
  50. # Create 2015 Physic room event
  51. phy_salle = SallePhy( name=u"Polytech salle 211",
  52. description=u"Salle informatique, présence de postes de travail",)
  53. DBSession.add(phy_salle)
  54. DBSession.flush()
  55. # Create matching room place (Name could change each year)
  56. salle = Salles(name=u"Mystère", description=u"Salle Mystère",
  57. phy_salle_id = phy_salle.uid,
  58. year_uid = jm2l.year_uid)
  59. DBSession.add(salle)