def objects(): #~ dblogger.info("Installing contacts demo fixture") # use --verbosity=2 User = resolve_model(settings.SITE.user_model) Company = resolve_model("contacts.Company") Session = resolve_model('tickets.Session') #~ u = User.objects.get(username='******') u = User.objects.all()[0] rumma = Company.objects.get(name=u'Rumma & Ko OÜ') project = Instantiator('tickets.Project',"name",user=u).build yield project("TIM") lino = project("Lino") yield lino presto = project("Presto",parent=lino) yield presto cbss = project("CBSS connection",parent=lino) yield cbss milestone = Instantiator('tickets.Milestone',"label reached",project=lino).build yield milestone('1.4.3',i2d(20120328)) yield milestone('1.4.5',i2d(20120716)) yield milestone('1.4.7',i2d(20120717)) yield milestone('1.4.8',i2d(20120722)) yield milestone('1.4.9',None) ticket = Instantiator('tickets.Ticket',"summary",user=u,project=presto,partner=rumma).build presto_proto = ticket(summary="write a first prototype",project=presto) yield presto_proto #~ session = Instantiator('tickets.Session',"description",user=u,ticket=t).build yield Session(date=i2d(20111113), user=u,ticket=presto_proto,start_time='21:45',end_time='23:28', description="""\ Created new module (tested in `lino_local.luc`). Tried first with EventsByTicket instead of Comments, but Comments are not usually planned.""") yield Session(date=i2d(20120603), user=u,ticket=presto_proto,start_time='21:45',end_time='23:28', description="""\ replaced Comment by Session. """) yield Session(date=i2d(20120604), user=u,ticket=presto_proto,start_time='08:10',end_time='10:30', description="""\ labels, titles, tidy up, EntriesBySession. """) yield Session(date=i2d(20120629), user=u,ticket=presto_proto,start_time='00:05',end_time='01:15', description="""\ ProjectsByPartner """) yield Session(date=i2d(20120727), user=u,ticket=presto_proto,start_time='02:30',end_time='03:15', description="""\ TicketsByPartner """)
def objects(self): yield super(Loader2, self).objects() topic = Instantiator('courses.Topic').build line = Instantiator('courses.Line', 'topic event_type fee').build course = Instantiator( 'courses.Course', 'line room start_time end_time').build booking = Instantiator( 'rooms.Booking', 'room start_time end_time').build TEACHERS = Cycler(Teacher.objects.all()) COMPANIES = Cycler(Company.objects.all()) USERS = Cycler(settings.SITE.user_model.objects.all()) def add_course(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) #~ kw.update(price=PRICES.pop()) return course(*args, **kw) Product = rt.models.products.Product ProductCat = rt.models.products.ProductCat journey_options = ProductCat(**dd.str2kw( 'name', _("Hotel options"))) yield journey_options option = Instantiator(Product, cat=journey_options).build yield option(**dd.str2kw('name', _("Single room"))) yield option(**dd.str2kw('name', _("Double room"))) yield option(**dd.str2kw('name', _("Triple room"))) # yield option(**dd.str2kw('name', _("Shower"))) # yield option(**dd.str2kw('name', _("Night club"))) # trip_options = ProductCat(**dd.str2kw('name', _("Trip options"))) # yield trip_options # option = Instantiator(Product, cat=trip_options).build # yield option(name="Eupen Oberstadt") # yield option(name="Eupen Unterstadt") # yield option(name="Raeren") # yield option(name="Kelmis") # yield option(name="Büllingen") journey = Instantiator( 'courses.Course', 'line name start_date end_date').build def add_journey(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) return journey(*args, **kw) self.journeys_topic = topic(**dd.str2kw('name', _("Journeys"))) yield self.journeys_topic europe = line(self.journeys_topic, None, self.journey_fee, options_cat=journey_options, **dd.str2kw('name', _("Europe"))) yield europe yield add_journey(europe, "Griechenland 2014", i2d(20140814), i2d(20140820)) yield add_journey(europe, "London 2014", i2d(20140714), i2d(20140720)) comp = topic(name="Computer") yield comp sport = topic(name="Sport") yield sport medit = topic(name="Meditation") yield medit externe = topic(name="Externe") yield externe obj = line(comp, self.kurse, self.PRICES.pop(), ref="comp", **dd.str2kw('name', _("First Steps"))) yield obj kw = dict(max_events=8) kw.update(max_places=20) kw.update(start_date=demo_date(-30)) kw.update(state=courses.CourseStates.active) kw.update(every=1) kw.update(every_unit=cal.Recurrencies.weekly) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) desc = """ Behandelte Themengebiete: - Grundlagen, Voraussetzungen - Arbeiten im WWW unter Verwendung eines Browsers - Navigieren im WWW - Links in die Linkleiste legen - aus Webseiten heraus drucken - Favoriten bzw. Lesezeichen verwenden - Aufgabe und Funktionsweise von Suchmaschinen - Elektronische Post: E-Mails verfassen, senden, empfangen, beantworten - E-Mails mit Anlagen - E-mail Sicherheit - Tipps und Tricks """ obj = line( comp, self.kurse, self.PRICES.pop(), ref="WWW", description=desc, **dd.str2kw( 'name', _("Internet for beginners"))) yield obj kw = dict(max_events=8) kw.update(start_date=demo_date(10)) kw.update(state=courses.CourseStates.active) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', _("Belly dancing"))) yield obj kw = dict(max_events=8) kw.update(max_places=10) kw.update(start_date=demo_date(20)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "19:00", "20:00", wednesday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', _("Functional gymnastics"))) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(start_date=demo_date(-10)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', _("Swimming"))) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(start_date=demo_date(-100)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) yield add_course(obj, self.pc_stvith, "11:00", "12:00", tuesday=True, **kw) yield add_course(obj, self.pc_stvith, "13:30", "14:30", tuesday=True, **kw) yield add_course(obj, self.pc_kelmis, "11:00", "12:00", thursday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "14:30", thursday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', "Self-defence")) yield obj kw = dict(max_events=6) kw.update(max_places=12) kw.update(start_date=demo_date(-80)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:00", friday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:00", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="GLQ", name="GuoLin-Qigong") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-10)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="MED", **dd.str2kw('name', _("Finding your inner peace"))) yield obj kw = dict(max_events=10) kw.update(max_places=30) kw.update(start_date=demo_date(-10)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), name="Yoga") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(60)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) EXTS = Cycler(self.ext1, self.ext2) def add_booking(*args, **kw): kw.update(user=USERS.pop()) kw.update(event_type=self.seminare) #~ kw.update(price=PRICES.pop()) #~ kw.update(tariff=PRICES.pop()) #~ kw.update(calendar=self.kurse) kw.update(every=1) kw.update(company=EXTS.pop()) return booking(*args, **kw) #~ obj = line(externe,self.kurse,PRICES.pop(),**dd.babelkw('name', #~ de="Raumbuchung",en="Room booking")) #~ yield obj kw = dict(max_events=10) kw.update(every_unit=cal.Recurrencies.weekly) kw.update(start_date=demo_date(60)) kw.update(state=BookingStates.registered) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", tuesday=True, **kw) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", thursday=True, **kw) kw = dict(max_events=1) kw.update(every_unit=cal.Recurrencies.once) kw.update(company=COMPANIES.pop()) kw.update(every_unit=cal.Recurrencies.once) yield add_booking(self.konf, "10:00", "14:00", **kw) PUPILS = Cycler(Pupil.objects.all()) #~ print 20130712, Pupil.objects.all() COURSES = Cycler(Course.objects.filter(line__fee__isnull=False)) STATES = Cycler(EnrolmentStates.objects()) for i in range(100): kw = dict( user=USERS.pop(), course=COURSES.pop(), pupil=PUPILS.pop()) kw.update(request_date=demo_date(-i)) kw.update(state=STATES.pop()) #~ print 20130712, kw yield Enrolment(**kw) #~ ses = settings.SITE.login('rolf') ses = settings.SITE.login() for model in (Course, Booking): for obj in model.objects.all(): rc = ses.run(obj.do_update_events) if not rc.get('success', False): raise Exception("update_reminders on %s returned %s" % (obj, rc))
from __future__ import unicode_literals from builtins import range from builtins import str import logging logger = logging.getLogger(__name__) from lino.utils.instantiator import Instantiator, i2d from lino.utils import Cycler from django.utils.translation import ugettext_lazy as _ from django.conf import settings from lino.utils import date_offset from lino.api import dd, rt DEMO_REF_DATE = i2d(20140101) cal = dd.resolve_app('cal') courses = dd.resolve_app('courses') rooms = dd.resolve_app('rooms') Booking = dd.resolve_model('rooms.Booking') Room = dd.resolve_model('cal.Room') Event = dd.resolve_model('cal.Event') Partner = dd.resolve_model('contacts.Partner') Company = dd.resolve_model('contacts.Company') Teacher = dd.resolve_model('courses.Teacher') TeacherType = dd.resolve_model('courses.TeacherType') Pupil = dd.resolve_model('courses.Pupil') PupilType = dd.resolve_model('courses.PupilType')
def objects(self): yield super(Loader2, self).objects() topic = Instantiator('courses.Topic').build line = Instantiator('courses.Line', 'topic event_type fee').build course = Instantiator( 'courses.Course', 'line room start_time end_time').build booking = Instantiator( 'rooms.Booking', 'room start_time end_time').build TEACHERS = Cycler(Teacher.objects.all()) COMPANIES = Cycler(Company.objects.all()) USERS = Cycler(settings.SITE.user_model.objects.all()) def add_course(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) #~ kw.update(price=PRICES.pop()) return course(*args, **kw) Product = rt.modules.products.Product ProductCat = rt.modules.products.ProductCat journey_options = ProductCat(**dd.str2kw( 'name', _("Hotel options"))) yield journey_options option = Instantiator(Product, cat=journey_options).build yield option(**dd.str2kw('name', _("Single room"))) yield option(**dd.str2kw('name', _("Double room"))) yield option(**dd.str2kw('name', _("Triple room"))) # yield option(**dd.str2kw('name', _("Shower"))) # yield option(**dd.str2kw('name', _("Night club"))) # trip_options = ProductCat(**dd.str2kw('name', _("Trip options"))) # yield trip_options # option = Instantiator(Product, cat=trip_options).build # yield option(name="Eupen Oberstadt") # yield option(name="Eupen Unterstadt") # yield option(name="Raeren") # yield option(name="Kelmis") # yield option(name="Büllingen") journey = Instantiator( 'courses.Course', 'line name start_date end_date').build def add_journey(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) return journey(*args, **kw) self.journeys_topic = topic(**dd.str2kw('name', _("Journeys"))) yield self.journeys_topic europe = line(self.journeys_topic, None, self.journey_fee, options_cat=journey_options, **dd.str2kw('name', _("Europe"))) yield europe yield add_journey(europe, "Griechenland 2014", i2d(20140814), i2d(20140820)) yield add_journey(europe, "London 2014", i2d(20140714), i2d(20140720)) comp = topic(name="Computer") yield comp sport = topic(name="Sport") yield sport medit = topic(name="Meditation") yield medit externe = topic(name="Externe") yield externe obj = line(comp, self.kurse, self.PRICES.pop(), ref="comp", **dd.str2kw('name', _("First Steps"))) yield obj kw = dict(max_events=8) kw.update(max_places=20) kw.update(start_date=demo_date(-30)) kw.update(state=courses.CourseStates.active) kw.update(every=1) kw.update(every_unit=cal.Recurrencies.weekly) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) desc = """ Behandelte Themengebiete: - Grundlagen, Voraussetzungen - Arbeiten im WWW unter Verwendung eines Browsers - Navigieren im WWW - Links in die Linkleiste legen - aus Webseiten heraus drucken - Favoriten bzw. Lesezeichen verwenden - Aufgabe und Funktionsweise von Suchmaschinen - Elektronische Post: E-Mails verfassen, senden, empfangen, beantworten - E-Mails mit Anlagen - E-mail Sicherheit - Tipps und Tricks """ obj = line( comp, self.kurse, self.PRICES.pop(), ref="WWW", description=desc, **dd.str2kw( 'name', _("Internet for beginners"))) yield obj kw = dict(max_events=8) kw.update(start_date=demo_date(10)) kw.update(state=courses.CourseStates.active) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', _("Belly dancing"))) yield obj kw = dict(max_events=8) kw.update(max_places=10) kw.update(start_date=demo_date(20)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "19:00", "20:00", wednesday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', _("Functional gymnastics"))) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(start_date=demo_date(-10)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', _("Swimming"))) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(start_date=demo_date(-100)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) yield add_course(obj, self.pc_stvith, "11:00", "12:00", tuesday=True, **kw) yield add_course(obj, self.pc_stvith, "13:30", "14:30", tuesday=True, **kw) yield add_course(obj, self.pc_kelmis, "11:00", "12:00", thursday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "14:30", thursday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), **dd.str2kw('name', "Self-defence")) yield obj kw = dict(max_events=6) kw.update(max_places=12) kw.update(start_date=demo_date(-80)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:00", friday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:00", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="GLQ", name="GuoLin-Qigong") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-10)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="MED", **dd.str2kw('name', _("Finding your inner peace"))) yield obj kw = dict(max_events=10) kw.update(max_places=30) kw.update(start_date=demo_date(-10)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), name="Yoga") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(60)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) EXTS = Cycler(self.ext1, self.ext2) def add_booking(*args, **kw): kw.update(user=USERS.pop()) kw.update(event_type=self.seminare) #~ kw.update(price=PRICES.pop()) #~ kw.update(tariff=PRICES.pop()) #~ kw.update(calendar=self.kurse) kw.update(every=1) kw.update(company=EXTS.pop()) return booking(*args, **kw) #~ obj = line(externe,self.kurse,PRICES.pop(),**dd.babelkw('name', #~ de="Raumbuchung",en="Room booking")) #~ yield obj kw = dict(max_events=10) kw.update(every_unit=cal.Recurrencies.weekly) kw.update(start_date=demo_date(60)) kw.update(state=BookingStates.registered) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", tuesday=True, **kw) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", thursday=True, **kw) kw = dict(max_events=1) kw.update(every_unit=cal.Recurrencies.once) kw.update(company=COMPANIES.pop()) kw.update(every_unit=cal.Recurrencies.once) yield add_booking(self.konf, "10:00", "14:00", **kw) PUPILS = Cycler(Pupil.objects.all()) #~ print 20130712, Pupil.objects.all() COURSES = Cycler(Course.objects.filter(line__fee__isnull=False)) STATES = Cycler(EnrolmentStates.objects()) for i in range(100): kw = dict( user=USERS.pop(), course=COURSES.pop(), pupil=PUPILS.pop()) kw.update(request_date=demo_date(-i)) kw.update(state=STATES.pop()) #~ print 20130712, kw yield Enrolment(**kw) #~ ses = settings.SITE.login('rolf') ses = settings.SITE.login() for model in (Course, Booking): for obj in model.objects.all(): rc = ses.run(obj.do_update_events) if not rc.get('success', False): raise Exception("update_reminders on %s returned %s" % (obj, rc))
""" from __future__ import unicode_literals import logging logger = logging.getLogger(__name__) from lino.utils.instantiator import Instantiator, i2d from lino.utils import Cycler from django.utils.translation import ugettext_lazy as _ from django.conf import settings from atelier.utils import date_offset from lino.api import dd, rt DEMO_REF_DATE = i2d(20140101) cal = dd.resolve_app('cal') courses = dd.resolve_app('courses') rooms = dd.resolve_app('rooms') Booking = dd.resolve_model('rooms.Booking') Room = dd.resolve_model('cal.Room') Event = dd.resolve_model('cal.Event') Partner = dd.resolve_model('contacts.Partner') Company = dd.resolve_model('contacts.Company') Teacher = dd.resolve_model('courses.Teacher') TeacherType = dd.resolve_model('courses.TeacherType') Pupil = dd.resolve_model('courses.Pupil') PupilType = dd.resolve_model('courses.PupilType')
def objects(self): yield super(Loader2, self).objects() Enrolment = rt.models.courses.Enrolment topic = Instantiator('courses.Topic').build line = Instantiator('courses.Line', 'topic event_type fee').build course = Instantiator( 'courses.Course', 'line room start_time end_time').build booking = Instantiator( 'rooms.Booking', 'room start_time end_time').build TEACHERS = Cycler(Teacher.objects.all()) COMPANIES = Cycler(Company.objects.all()) USERS = Cycler(settings.SITE.user_model.objects.all()) def add_course(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) #~ kw.update(price=PRICES.pop()) obj = course(*args, **kw) if obj.line.fee.tariff and obj.line.fee.tariff.number_of_events: obj.max_events = None return obj Product = rt.models.products.Product ProductCat = rt.models.products.ProductCat CourseAreas = rt.models.courses.CourseAreas PaymentTerm = rt.models.ledger.PaymentTerm journey_options = ProductCat(**dd.str2kw( 'name', _("Hotel options"))) yield journey_options option = Instantiator(Product, cat=journey_options).build yield option(**dd.str2kw('name', _("Single room"))) yield option(**dd.str2kw('name', _("Double room"))) yield option(**dd.str2kw('name', _("Triple room"))) # yield option(**dd.str2kw('name', _("Shower"))) # yield option(**dd.str2kw('name', _("Night club"))) # trip_options = ProductCat(**dd.str2kw('name', _("Trip options"))) # yield trip_options # option = Instantiator(Product, cat=trip_options).build # yield option(name="Eupen Oberstadt") # yield option(name="Eupen Unterstadt") # yield option(name="Raeren") # yield option(name="Kelmis") # yield option(name="Büllingen") journey = Instantiator( 'courses.Course', 'line name start_date end_date').build def add_journey(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) kw.update(every_unit=cal.Recurrencies.once) kw.update(payment_term=PaymentTerm.get_by_ref('P30')) return journey(*args, **kw) self.journeys_topic = topic(**dd.str2kw('name', _("Journeys"))) yield self.journeys_topic europe = line(self.journeys_topic, self.excursions, self.journey_fee, options_cat=journey_options, course_area=CourseAreas.journeys, fees_cat=self.journeys_cat, **dd.str2kw('name', _("Europe"))) yield europe yield add_journey(europe, "Greece 2014", i2d(20140814), i2d(20140820), state=courses.CourseStates.active) yield add_journey(europe, "London 2014", i2d(20140714), i2d(20140720)) comp = topic(name="Computer") yield comp sport = topic(name="Sport") yield sport medit = topic(name="Meditation") yield medit externe = topic(name="Externe") yield externe obj = line(comp, self.kurse, self.PRICES.pop(), fees_cat=self.course_fees, ref="comp", **dd.babelkw('name', de="Erste Schritte", en="First Steps")) yield obj kw = dict(max_events=8) kw.update(max_places=3) kw.update(start_date=demo_date(-430)) kw.update(state=courses.CourseStates.active) kw.update(every=1) kw.update(every_unit=cal.Recurrencies.weekly) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) desc = """ Behandelte Themengebiete: - Grundlagen, Voraussetzungen - Arbeiten im WWW unter Verwendung eines Browsers - Navigieren im WWW - Links in die Linkleiste legen - aus Webseiten heraus drucken - Favoriten bzw. Lesezeichen verwenden - Aufgabe und Funktionsweise von Suchmaschinen - Elektronische Post: E-Mails verfassen, senden, empfangen, beantworten - E-Mails mit Anlagen - E-mail Sicherheit - Tipps und Tricks """ obj = line( comp, self.kurse, self.PRICES.pop(), ref="WWW", fees_cat=self.course_fees, description=desc, **dd.babelkw( 'name', de="Internet: World Wide Web für Anfänger", en="Internet for beginners")) yield obj kw = dict(max_events=8) kw.update(max_places=4) kw.update(start_date=demo_date(-210)) kw.update(state=courses.CourseStates.active) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="BT", fees_cat=self.course_fees, **dd.babelkw('name', de="Bauchtanz", en="Belly dancing")) yield obj kw = dict(max_events=8) kw.update(max_places=10) kw.update(start_date=demo_date(-420)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "19:00", "20:00", wednesday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="FG", fees_cat=self.course_fees, **dd.babelkw('name', de="Funktionsgymnastik", en="Functional gymnastics")) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(max_places=5) kw.update(start_date=demo_date(-230)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="Rücken", fees_cat=self.course_fees, **dd.babelkw('name', de="Rücken fit durch Schwimmen", en="Swimming")) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(max_places=20) kw.update(start_date=demo_date(50)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) yield add_course(obj, self.pc_stvith, "11:00", "12:00", tuesday=True, **kw) yield add_course(obj, self.pc_stvith, "13:30", "14:30", tuesday=True, **kw) yield add_course(obj, self.pc_kelmis, "11:00", "12:00", thursday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "14:30", thursday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="SV", fees_cat=self.course_fees, **dd.babelkw('name', de="Selbstverteidigung im Alltag", en="Self-defence")) yield obj kw = dict(max_events=6) kw.update(max_places=12) kw.update(start_date=demo_date(-80)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:00", friday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:00", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="GLQ", fees_cat=self.course_fees, name="GuoLin-Qigong") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-310)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="MED", fees_cat=self.course_fees, **dd.babelkw( 'name', de="Den Kopf frei machen - zur inneren Ruhe finden", en="Finding your inner peace")) yield obj kw = dict(max_events=10) kw.update(max_places=30) kw.update(start_date=demo_date(-610)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) kw.update(start_date=demo_date(-110)) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), name="Yoga") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-560)) kw.update(max_places=20) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) for obj in Course.objects.filter(ref__isnull=True): if obj.line.fee.tariff and obj.line.fee.tariff.number_of_events: obj.ref = "%03dC" % obj.id else: obj.ref = "%03d" % obj.id yield obj EXTS = Cycler(self.ext1, self.ext2) def add_booking(*args, **kw): kw.update(user=USERS.pop()) kw.update(event_type=self.seminare) #~ kw.update(price=PRICES.pop()) #~ kw.update(fee=PRICES.pop()) #~ kw.update(calendar=self.kurse) kw.update(every=1) kw.update(company=EXTS.pop()) return booking(*args, **kw) #~ obj = line(externe,self.kurse,PRICES.pop(),**dd.babelkw('name', #~ de="Raumbuchung",en="Room booking")) #~ yield obj kw = dict(max_events=10) kw.update(every_unit=cal.Recurrencies.weekly) kw.update(start_date=demo_date(160)) kw.update(state=BookingStates.registered) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", tuesday=True, **kw) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", thursday=True, **kw) kw = dict(max_events=1) kw.update(every_unit=cal.Recurrencies.once) kw.update(company=COMPANIES.pop()) kw.update(every_unit=cal.Recurrencies.once) yield add_booking(self.konf, "10:00", "14:00", **kw) # a series of five week-ends: kw = dict() kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) kw.update(every_unit=cal.Recurrencies.monthly) kw.update(max_events=5) kw.update(friday=True) kw.update(payment_term=PaymentTerm.get_by_ref('P30')) yield journey(europe, "Five Weekends 2015", i2d(20150619), i2d(20150621), **kw) # PUPILS = Cycler() #~ print 20130712, Pupil.objects.all() COURSES = Cycler(Course.objects.filter( line__fee__isnull=False).order_by('room__company__city')) # STATES = Cycler(EnrolmentStates.objects()) FREE_EVENTS = Cycler([3, 2, 5, -2]) # assert len(USERS) > 1 pupils = Pupil.objects.order_by('id') # print("20171028 {} courses, {} pupils".format( # len(COURSES), pupils.count())) # assert pupils.count() == 50 n = 0 for pupil in pupils: for i in range(pupil.id % 6): n += 1 # every pupil can be in up to 5 courses. That's a bit # unrealistic, but we have 25 courses and 35 # pupils and want to have course = COURSES.pop() def coursedate(*args, **kwargs): return date_offset(course.start_date, *args, **kwargs) kw = dict(user=USERS.pop(), course=course, pupil=pupil) #~ print 20130712, kw story = ENROLMENT_STORIES.pop() assert isinstance(story, list) for rd, sd, ed in story: # kw.update(state=STATES.pop()) # enrolments are requested from 3 weeks before until 1 # week after start date of course: # kw.update(request_date=coursedate(i % 28 - 7)) kw.update(request_date=coursedate(rd)) if course.line == europe: if n % 3 == 0: kw.update(places=2) obj = Enrolment(**kw) # print("20171027b {}".format(obj)) obj.full_clean() if sd is not None: obj.start_date = coursedate(sd) # obj.request_date = obj.start_date if ed is not None: obj.end_date = coursedate(ed) if n % 10 == 0: obj.state = EnrolmentStates.requested elif n % 13 == 0: obj.state = EnrolmentStates.cancelled else: obj.state = EnrolmentStates.confirmed if n % 9 == 0: if course.line.fee.tariff: if course.line.fee.tariff.number_of_events: obj.free_events = FREE_EVENTS.pop() yield obj ses = settings.SITE.login() for model in (Course, Booking): for obj in model.objects.all(): rc = ses.run(obj.do_update_events) if not rc.get('success', False): raise Exception("update_reminders on %s returned %s" % (obj, rc)) Event = rt.models.cal.Event EntryStates = rt.models.cal.EntryStates qs = Event.objects.filter( start_date__lt=dd.demo_date()).order_by('id') for i, e in enumerate(qs): if i % 8: e.state = EntryStates.took_place yield e
def objects(self): yield super(Loader2, self).objects() Enrolment = rt.models.courses.Enrolment topic = Instantiator('courses.Topic').build line = Instantiator('courses.Line', 'topic event_type fee').build course = Instantiator('courses.Course', 'line room start_time end_time').build booking = Instantiator('rooms.Booking', 'room start_time end_time').build TEACHERS = Cycler(Teacher.objects.all()) COMPANIES = Cycler(Company.objects.all()) # USERS = Cycler(settings.SITE.user_model.objects.all()) cal_users = [ ut for ut in UserTypes.get_list_items() if ut.has_required_roles([OfficeUser]) ] USERS = Cycler( settings.SITE.user_model.objects.filter(user_type__in=cal_users)) def add_course(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) #~ kw.update(price=PRICES.pop()) obj = course(*args, **kw) if obj.line.fee.tariff and obj.line.fee.tariff.number_of_events: obj.max_events = None return obj Product = rt.models.products.Product ProductCat = rt.models.products.ProductCat ActivityLayouts = rt.models.courses.ActivityLayouts PaymentTerm = rt.models.ledger.PaymentTerm journey_options = ProductCat(**dd.str2kw('name', _("Hotel options"))) yield journey_options option = Instantiator(Product, cat=journey_options).build yield option(**dd.str2kw('name', _("Single room"))) yield option(**dd.str2kw('name', _("Double room"))) yield option(**dd.str2kw('name', _("Triple room"))) # yield option(**dd.str2kw('name', _("Shower"))) # yield option(**dd.str2kw('name', _("Night club"))) # trip_options = ProductCat(**dd.str2kw('name', _("Trip options"))) # yield trip_options # option = Instantiator(Product, cat=trip_options).build # yield option(name="Eupen Oberstadt") # yield option(name="Eupen Unterstadt") # yield option(name="Raeren") # yield option(name="Kelmis") # yield option(name="Büllingen") journey = Instantiator('courses.Course', 'line name start_date end_date').build def add_journey(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) kw.update(every_unit=cal.Recurrencies.once) kw.update(payment_term=PaymentTerm.get_by_ref('P30')) return journey(*args, **kw) self.journeys_topic = topic(**dd.str2kw('name', _("Journeys"))) yield self.journeys_topic europe = line(self.journeys_topic, self.excursions, self.journey_fee, options_cat=journey_options, course_area=ActivityLayouts.journeys, fees_cat=self.journeys_cat, **dd.str2kw('name', _("Europe"))) yield europe yield add_journey(europe, "Greece 2021", i2d(20140814), i2d(20140820), state=courses.CourseStates.active) yield add_journey(europe, "London 2022", i2d(20140714), i2d(20140720)) comp = topic(name="Latin") yield comp sport = topic(name="Sport") yield sport medit = topic(name="Vienna") yield medit externe = topic(name="Externe") yield externe obj = line(comp, self.kurse, self.PRICES.pop(), fees_cat=self.course_fees, ref="comp", **dd.str2kw('name', _("First Steps"))) yield obj kw = dict(max_events=8) kw.update(max_places=3) kw.update(start_date=demo_date(-430)) kw.update(state=courses.CourseStates.active) kw.update(every=1) kw.update(every_unit=cal.Recurrencies.weekly) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) desc = """ bla bla bla. """ obj = line(comp, self.kurse, self.PRICES.pop(), ref="WWW", fees_cat=self.course_fees, description=desc, **dd.str2kw('name', _("Master class"))) yield obj kw = dict(max_events=8) kw.update(max_places=4) kw.update(start_date=demo_date(-210)) kw.update(state=courses.CourseStates.active) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="BT", fees_cat=self.course_fees, **dd.str2kw('name', _("Belly dancing"))) yield obj kw = dict(max_events=8) kw.update(max_places=10) kw.update(start_date=demo_date(-420)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "19:00", "20:00", wednesday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="FG", fees_cat=self.course_fees, **dd.str2kw('name', _("Functional gymnastics"))) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(max_places=5) kw.update(start_date=demo_date(-230)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="Rücken", fees_cat=self.course_fees, **dd.str2kw('name', _("Swimming"))) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(max_places=20) kw.update(start_date=demo_date(50)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) yield add_course(obj, self.pc_stvith, "11:00", "12:00", tuesday=True, **kw) yield add_course(obj, self.pc_stvith, "13:30", "14:30", tuesday=True, **kw) yield add_course(obj, self.pc_kelmis, "11:00", "12:00", thursday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "14:30", thursday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="SV", fees_cat=self.course_fees, **dd.str2kw('name', _("Self-defence"))) yield obj kw = dict(max_events=6) kw.update(max_places=12) kw.update(start_date=demo_date(-80)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:00", friday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:00", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="GLQ", fees_cat=self.course_fees, name="GuoLin-Qigong") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-310)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="MED", fees_cat=self.course_fees, **dd.babelkw( 'name', de="Den Kopf frei machen - zur inneren Ruhe finden", en="Finding your inner peace")) yield obj kw = dict(max_events=10) kw.update(max_places=30) kw.update(start_date=demo_date(-610)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) kw.update(start_date=demo_date(-110)) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), name="Yoga") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-560)) kw.update(max_places=20) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) for obj in Course.objects.filter(ref__isnull=True): if obj.line.fee.tariff and obj.line.fee.tariff.number_of_events: obj.ref = "%03dC" % obj.id else: obj.ref = "%03d" % obj.id yield obj EXTS = Cycler(self.ext1, self.ext2) def add_booking(*args, **kw): kw.update(user=USERS.pop()) kw.update(event_type=self.seminare) #~ kw.update(price=PRICES.pop()) #~ kw.update(fee=PRICES.pop()) #~ kw.update(calendar=self.kurse) kw.update(every=1) kw.update(company=EXTS.pop()) return booking(*args, **kw) #~ obj = line(externe,self.kurse,PRICES.pop(),**dd.babelkw('name', #~ de="Raumbuchung",en="Room booking")) #~ yield obj kw = dict(max_events=10) kw.update(every_unit=cal.Recurrencies.weekly) kw.update(start_date=demo_date(160)) kw.update(state=BookingStates.registered) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", tuesday=True, **kw) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", thursday=True, **kw) kw = dict(max_events=1) kw.update(every_unit=cal.Recurrencies.once) kw.update(company=COMPANIES.pop()) kw.update(every_unit=cal.Recurrencies.once) yield add_booking(self.konf, "10:00", "14:00", **kw) # a series of five week-ends: kw = dict() kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) kw.update(every_unit=cal.Recurrencies.monthly) kw.update(max_events=5) kw.update(friday=True) kw.update(payment_term=PaymentTerm.get_by_ref('P30')) yield journey(europe, "Five Weekends 2020", i2d(20200619), i2d(20200621), **kw) PUPILS = Cycler(Pupil.objects.all()) kw = dict(state=EnrolmentStates.confirmed) for course in Course.objects.all(): kw.update(user=USERS.pop(), course=course) for i in range(2): kw.update(pupil=PUPILS.pop()) obj = Enrolment(**kw) yield obj ses = settings.SITE.login() for model in (Course, Booking): for obj in model.objects.all(): rc = ses.run(obj.do_update_events) if not rc.get('success', False): raise Exception("update_reminders on %s returned %s" % (obj, rc)) Event = rt.models.cal.Event EntryStates = rt.models.cal.EntryStates qs = Event.objects.filter(start_date__lt=dd.demo_date()).order_by('id') for i, e in enumerate(qs): if i % 8: e.state = EntryStates.took_place yield e
def objects(): Company = dd.resolve_model("contacts.Company") Customer = dd.resolve_model('sales.Customer') products = dd.resolve_app('products') sales = dd.resolve_app('sales') salesrule = Instantiator(sales.SalesRule).build #customer = Instantiator(Customer).build imode = Instantiator(sales.InvoicingMode, "id channel name advance_days journal").build for c in Company.objects.filter(country_id='BE'): yield c.contact_ptr.insert_child(Customer) paymentterm = Instantiator(sales.PaymentTerm,"id name").build yield paymentterm("pp","Prepayment",days=7) yield paymentterm("cash","Cash") yield paymentterm("7","7 days net",days=7) pt15 = paymentterm("15","15 days net",days=15) yield pt15 yield paymentterm("30","30 days net",days=30) shippingmode = Instantiator(sales.ShippingMode,"id name").build yield shippingmode("ta","take away") yield shippingmode("rm","regular mail") #~ for company in Company.objects.all(): #~ yield Customer(company=company) #~ for person in Person.objects.all(): #~ yield Customer(person=person) #ORD = journals.get_journal_by_docclass(Order) #INV = journals.get_journal_by_docclass(Invoice) ORD = sales.Order.create_journal("ORD",name="Orders",printed_name="Order # %d") #ORD = journals.get_journal("ORD") #INV = journals.get_journal("INV") yield ORD INV = sales.Invoice.create_journal("INV",\ account=ledger.Account.objects.get(match="4000"), name="Invoices",printed_name="Invoice # %d") #~ INV = sales.Invoice.create_journal("INV",account="4000",name="Invoices") yield INV imode_e = imode('e','E','By e-mail',2,INV,template='order_invoice.odt',build_method='appyodt') yield imode_e imode_p = imode('p','P','By snail mail',10,INV,template='order_invoice.odt',build_method='appyodt') yield imode_p yield salesrule(imode='e',shipping_mode="ta",payment_term="7") #~ Company = resolve_model('contacts.Company') #Person = resolve_model('contacts.Person') #company1 = Company.objects.get(name__startswith="Ausdemwald") #dubois = Person.objects.get(last_name__startswith="Dubois") furniture = products.ProductCat.objects.get(pk=1) # name="Furniture") hosting = products.Product.objects.get(pk=5) #~ order = Instantiator(sales.Order, #~ "company creation_date start_date cycle imode", #~ payment_term="30",journal=ORD).build #~ invoice = Instantiator(sales.Invoice, #~ "company creation_date imode", #~ payment_term="30",journal=INV).build o = ORD.create_document( customer=Customer.objects.all()[0], #~ company=Company.objects.get(pk=1), creation_date=i2d(20080923),start_date=i2d(20080924), cycle="M",imode=imode_e, sales_remark="monthly order") #~ o = order(1,"2008-09-23","2008-09-24","M","e",sales_remark="monthly order") o.add_item(hosting,1) yield o o = ORD.create_document( customer=Customer.objects.all()[1], #~ company=Company.objects.get(pk=2), creation_date=i2d(20080923),start_date=i2d(20080924), cycle="M",imode=imode_e, sales_remark="Customer 2 gets 50% discount") #~ o = order(2,"2008-09-23","2008-09-24","M","e", #~ sales_remark="Company 2 gets 50% discount") o.add_item(hosting,1,discount=50) yield o utils.make_invoices(make_until=date(2008,10,28)) i = INV.create_document( customer=Customer.objects.all()[1], #~ company=Company.objects.get(pk=2), creation_date=i2d(20081029), imode=imode_e, sales_remark="first manual invoice") #~ i = invoice(2,"2008-10-29","e", #~ sales_remark="first manual invoice") i.add_item(1,1) i.add_item(2,4) yield i utils.make_invoices(make_until=date(2009,04,11)) i = INV.create_document( customer=Customer.objects.all()[2], #~ company=Company.objects.get(pk=3), creation_date=i2d(20090411), imode=imode_e, sales_remark="second manual invoice") #~ i = invoice(3,date(2009,04,11),"e", #~ sales_remark="second manual invoice") i.add_item(3,1) i.add_item(4,4) yield i #d = '2009-04-12' #d = '20090412' d = i2d(20090412) #d = date(2009,4,12) #~ o2 = order(4,d,d,"Y","p",sales_remark="yearly order") o2 = ORD.create_document( customer=Customer.objects.all()[3], #~ company=Company.objects.get(pk=4), creation_date=d,start_date=d, cycle="Y",imode=imode_p, sales_remark="yearly order") o2.add_item(3,1) o2.add_item(4,4) #print o2 #o2.save() yield o2 utils.make_invoices(make_until=d) #~ i = invoice(4,date(2009,04,13),"e", #~ sales_remark="third manual invoice with discount") i = INV.create_document( customer=Customer.objects.all()[3], #~ company=Company.objects.get(pk=4), creation_date=i2d(20090413), imode=imode_e, sales_remark="third manual invoice with discount") i.add_item(3,1,discount=10) i.add_item(4,4,discount=5) yield i utils.make_invoices(make_until=date(2009,05,14)) #~ order = Instantiator(sales.Order,journal=ORD,cycle='M',imode='e',payment_term="15").build i = 0 for cust in Customer.objects.order_by('id'): i += 1 #~ for i in range(10): #for i in range(29): #~ o = order( #~ company=i+1,creation_date=date(2009,6,1+i), #~ sales_remark="range demo #%d" % i) o = ORD.create_document( cycle='M',imode=imode_e,payment_term=pt15, customer=cust, #~ company=Company.objects.get(pk=i+1), creation_date=date(2009,6,i), sales_remark="range demo #%d" % i) yield o yield o.add_item(5,1,unit_price=1.7*i) utils.make_invoices(make_until=date(2009,7,1)) utils.make_invoices(make_until=date(2009,8,1)) utils.make_invoices(make_until=date(2009,10,1))
def objects(): # ~ dblogger.info("Installing contacts demo fixture") # use --verbosity=2 User = resolve_model(settings.SITE.user_model) Company = resolve_model("contacts.Company") Session = resolve_model('tickets.Session') #~ u = User.objects.get(username='******') u = User.objects.all()[0] rumma = Company.objects.get(name=u'Rumma & Ko OÜ') project = Instantiator('tickets.Project', "name", user=u).build yield project("TIM") lino = project("Lino") yield lino presto = project("Presto", parent=lino) yield presto cbss = project("CBSS connection", parent=lino) yield cbss milestone = Instantiator('tickets.Milestone', "label reached", project=lino).build yield milestone('1.4.3', i2d(20120328)) yield milestone('1.4.5', i2d(20120716)) yield milestone('1.4.7', i2d(20120717)) yield milestone('1.4.8', i2d(20120722)) yield milestone('1.4.9', None) ticket = Instantiator('tickets.Ticket', "summary", user=u, project=presto, partner=rumma).build presto_proto = ticket(summary="write a first prototype", project=presto) yield presto_proto #~ session = Instantiator('tickets.Session',"description",user=u,ticket=t).build yield Session(date=i2d(20111113), user=u, ticket=presto_proto, start_time='21:45', end_time='23:28', description="""\ Created new module (tested in `lino_local.luc`). Tried first with EventsByTicket instead of Comments, but Comments are not usually planned.""") yield Session(date=i2d(20120603), user=u, ticket=presto_proto, start_time='21:45', end_time='23:28', description="""\ replaced Comment by Session. """) yield Session(date=i2d(20120604), user=u, ticket=presto_proto, start_time='08:10', end_time='10:30', description="""\ labels, titles, tidy up, EntriesBySession. """) yield Session(date=i2d(20120629), user=u, ticket=presto_proto, start_time='00:05', end_time='01:15', description="""\ ProjectsByPartner """) yield Session(date=i2d(20120727), user=u, ticket=presto_proto, start_time='02:30', end_time='03:15', description="""\ TicketsByPartner """)
def objects(self): yield super(Loader2, self).objects() Enrolment = rt.models.courses.Enrolment topic = Instantiator('courses.Topic').build line = Instantiator('courses.Line', 'topic event_type fee').build course = Instantiator( 'courses.Course', 'line room start_time end_time').build booking = Instantiator( 'rooms.Booking', 'room start_time end_time').build TEACHERS = Cycler(Teacher.objects.all()) COMPANIES = Cycler(Company.objects.all()) USERS = Cycler(settings.SITE.user_model.objects.all()) def add_course(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) #~ kw.update(price=PRICES.pop()) obj = course(*args, **kw) if obj.line.fee.number_of_events: obj.max_events = None return obj Product = rt.models.products.Product ProductCat = rt.models.products.ProductCat CourseAreas = rt.models.courses.CourseAreas PaymentTerm = rt.models.ledger.PaymentTerm journey_options = ProductCat(**dd.str2kw( 'name', _("Hotel options"))) yield journey_options option = Instantiator(Product, cat=journey_options).build yield option(**dd.str2kw('name', _("Single room"))) yield option(**dd.str2kw('name', _("Double room"))) yield option(**dd.str2kw('name', _("Triple room"))) # yield option(**dd.str2kw('name', _("Shower"))) # yield option(**dd.str2kw('name', _("Night club"))) # trip_options = ProductCat(**dd.str2kw('name', _("Trip options"))) # yield trip_options # option = Instantiator(Product, cat=trip_options).build # yield option(name="Eupen Oberstadt") # yield option(name="Eupen Unterstadt") # yield option(name="Raeren") # yield option(name="Kelmis") # yield option(name="Büllingen") journey = Instantiator( 'courses.Course', 'line name start_date end_date').build def add_journey(*args, **kw): kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) kw.update(every_unit=cal.Recurrencies.once) kw.update(payment_term=PaymentTerm.get_by_ref('P30')) return journey(*args, **kw) self.journeys_topic = topic(**dd.str2kw('name', _("Journeys"))) yield self.journeys_topic europe = line(self.journeys_topic, self.excursions, self.journey_fee, options_cat=journey_options, course_area=CourseAreas.journeys, fees_cat=self.journeys_cat, **dd.str2kw('name', _("Europe"))) yield europe yield add_journey(europe, "Greece 2014", i2d(20140814), i2d(20140820), state=courses.CourseStates.active) yield add_journey(europe, "London 2014", i2d(20140714), i2d(20140720)) comp = topic(name="Computer") yield comp sport = topic(name="Sport") yield sport medit = topic(name="Meditation") yield medit externe = topic(name="Externe") yield externe obj = line(comp, self.kurse, self.PRICES.pop(), fees_cat=self.course_fees, ref="comp", **dd.babelkw('name', de="Erste Schritte", en="First Steps")) yield obj kw = dict(max_events=8) kw.update(max_places=3) kw.update(start_date=demo_date(-430)) kw.update(state=courses.CourseStates.active) kw.update(every=1) kw.update(every_unit=cal.Recurrencies.weekly) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) desc = """ Behandelte Themengebiete: - Grundlagen, Voraussetzungen - Arbeiten im WWW unter Verwendung eines Browsers - Navigieren im WWW - Links in die Linkleiste legen - aus Webseiten heraus drucken - Favoriten bzw. Lesezeichen verwenden - Aufgabe und Funktionsweise von Suchmaschinen - Elektronische Post: E-Mails verfassen, senden, empfangen, beantworten - E-Mails mit Anlagen - E-mail Sicherheit - Tipps und Tricks """ obj = line( comp, self.kurse, self.PRICES.pop(), ref="WWW", fees_cat=self.course_fees, description=desc, **dd.babelkw( 'name', de="Internet: World Wide Web für Anfänger", en="Internet for beginners")) yield obj kw = dict(max_events=8) kw.update(max_places=4) kw.update(start_date=demo_date(-210)) kw.update(state=courses.CourseStates.active) yield add_course(obj, self.pc_bbach, "13:30", "15:00", monday=True, **kw) yield add_course(obj, self.pc_eupen, "17:30", "19:00", wednesday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "15:00", friday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="BT", fees_cat=self.course_fees, **dd.babelkw('name', de="Bauchtanz", en="Belly dancing")) yield obj kw = dict(max_events=8) kw.update(max_places=10) kw.update(start_date=demo_date(-420)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "19:00", "20:00", wednesday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="FG", fees_cat=self.course_fees, **dd.babelkw('name', de="Funktionsgymnastik", en="Functional gymnastics")) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(max_places=5) kw.update(start_date=demo_date(-230)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="Rücken", fees_cat=self.course_fees, **dd.babelkw('name', de="Rücken fit durch Schwimmen", en="Swimming")) yield obj kw = dict(max_events=10, state=CourseStates.active) kw.update(max_places=20) kw.update(start_date=demo_date(50)) yield add_course(obj, self.spiegel, "11:00", "12:00", monday=True, **kw) yield add_course(obj, self.spiegel, "13:30", "14:30", monday=True, **kw) yield add_course(obj, self.pc_stvith, "11:00", "12:00", tuesday=True, **kw) yield add_course(obj, self.pc_stvith, "13:30", "14:30", tuesday=True, **kw) yield add_course(obj, self.pc_kelmis, "11:00", "12:00", thursday=True, **kw) yield add_course(obj, self.pc_kelmis, "13:30", "14:30", thursday=True, **kw) obj = line(sport, self.kurse, self.PRICES.pop(), ref="SV", fees_cat=self.course_fees, **dd.babelkw('name', de="Selbstverteidigung im Alltag", en="Self-defence")) yield obj kw = dict(max_events=6) kw.update(max_places=12) kw.update(start_date=demo_date(-80)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:00", friday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:00", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="GLQ", fees_cat=self.course_fees, name="GuoLin-Qigong") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-310)) kw.update(state=CourseStates.active) yield add_course(obj, self.spiegel, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.spiegel, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), ref="MED", fees_cat=self.course_fees, **dd.babelkw( 'name', de="Den Kopf frei machen - zur inneren Ruhe finden", en="Finding your inner peace")) yield obj kw = dict(max_events=10) kw.update(max_places=30) kw.update(start_date=demo_date(-610)) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) kw.update(start_date=demo_date(-110)) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) obj = line(medit, self.kurse, self.PRICES.pop(), name="Yoga") yield obj kw = dict(max_events=10) kw.update(start_date=demo_date(-560)) kw.update(max_places=20) kw.update(state=CourseStates.active) yield add_course(obj, self.konf, "18:00", "19:30", monday=True, **kw) yield add_course(obj, self.konf, "19:00", "20:30", friday=True, **kw) for obj in Course.objects.filter(ref__isnull=True): if obj.line.fee.number_of_events: obj.ref = "%03dC" % obj.id else: obj.ref = "%03d" % obj.id yield obj EXTS = Cycler(self.ext1, self.ext2) def add_booking(*args, **kw): kw.update(user=USERS.pop()) kw.update(event_type=self.seminare) #~ kw.update(price=PRICES.pop()) #~ kw.update(fee=PRICES.pop()) #~ kw.update(calendar=self.kurse) kw.update(every=1) kw.update(company=EXTS.pop()) return booking(*args, **kw) #~ obj = line(externe,self.kurse,PRICES.pop(),**dd.babelkw('name', #~ de="Raumbuchung",en="Room booking")) #~ yield obj kw = dict(max_events=10) kw.update(every_unit=cal.Recurrencies.weekly) kw.update(start_date=demo_date(160)) kw.update(state=BookingStates.registered) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", tuesday=True, **kw) kw.update(company=COMPANIES.pop()) yield add_booking(self.konf, "20:00", "22:00", thursday=True, **kw) kw = dict(max_events=1) kw.update(every_unit=cal.Recurrencies.once) kw.update(company=COMPANIES.pop()) kw.update(every_unit=cal.Recurrencies.once) yield add_booking(self.konf, "10:00", "14:00", **kw) # a series of five week-ends: kw = dict() kw.update(user=USERS.pop()) kw.update(teacher=TEACHERS.pop()) kw.update(every_unit=cal.Recurrencies.monthly) kw.update(max_events=5) kw.update(friday=True) kw.update(payment_term=PaymentTerm.get_by_ref('P30')) yield journey(europe, "Five Weekends 2015", i2d(20150619), i2d(20150621), **kw) # PUPILS = Cycler() #~ print 20130712, Pupil.objects.all() COURSES = Cycler(Course.objects.filter( line__fee__isnull=False).order_by('room__company__city')) # STATES = Cycler(EnrolmentStates.objects()) FREE_EVENTS = Cycler([3, 2, 5, -2]) # assert len(USERS) > 1 pupils = Pupil.objects.order_by('id') # print("20171028 {} courses, {} pupils".format( # len(COURSES), pupils.count())) # assert pupils.count() == 50 n = 0 for pupil in pupils: for i in range(pupil.id % 6): n += 1 # every pupil can be in up to 5 courses. That's a bit # unrealistic, but we have 25 courses and 35 # pupils and want to have course = COURSES.pop() def coursedate(*args, **kwargs): return date_offset(course.start_date, *args, **kwargs) kw = dict(user=USERS.pop(), course=course, pupil=pupil) #~ print 20130712, kw story = ENROLMENT_STORIES.pop() assert isinstance(story, list) for rd, sd, ed in story: # kw.update(state=STATES.pop()) # enrolments are requested from 3 weeks before until 1 # week after start date of course: # kw.update(request_date=coursedate(i % 28 - 7)) kw.update(request_date=coursedate(rd)) if course.line == europe: if n % 3 == 0: kw.update(places=2) obj = Enrolment(**kw) # print("20171027b {}".format(obj)) obj.full_clean() if sd is not None: obj.start_date = coursedate(sd) # obj.request_date = obj.start_date if ed is not None: obj.end_date = coursedate(ed) if n % 10 == 0: obj.state = EnrolmentStates.requested elif n % 13 == 0: obj.state = EnrolmentStates.cancelled else: obj.state = EnrolmentStates.confirmed if n % 9 == 0: if course.line.fee.number_of_events: obj.free_events = FREE_EVENTS.pop() yield obj ses = settings.SITE.login() for model in (Course, Booking): for obj in model.objects.all(): rc = ses.run(obj.do_update_events) if not rc.get('success', False): raise Exception("update_reminders on %s returned %s" % (obj, rc)) Event = rt.models.cal.Event EntryStates = rt.models.cal.EntryStates qs = Event.objects.filter( start_date__lt=dd.demo_date()).order_by('id') for i, e in enumerate(qs): if i % 8: e.state = EntryStates.took_place yield e