def objects(): #~ slot = Instantiator('courses.Slot','name start_time end_time').build #~ #~ kw = dict(monday=True,tuesday=True,wednesday=False,thursday=True,friday=True) #~ yield slot("Erste Stunde","16:00","17:00",**kw) #~ yield slot("Zweite Stunde","17:00","18:00",**kw) #~ yield slot("Dritte Stunde","18:00","19:00",**kw) #~ #~ kw = dict(wednesday=True) #~ yield slot("Mittwochs 13 Uhr","13:00","14:00",**kw) #~ yield slot("Mittwochs 14 Uhr","14:00","15:00",**kw) #~ yield slot("Mittwochs 15 Uhr","15:00","16:00",**kw) #~ yield slot("Mittwochs 16 Uhr","16:00","17:00",**kw) #~ yield slot("Mittwochs 17 Uhr","17:00","18:00",**kw) #~ yield slot("Mittwochs 18 Uhr","18:00","19:00",**kw) courses = dd.resolve_app('courses') yield courses.Line(**babelkw('name', de=u"Deutsch Anfänger", fr=u"Allemand débutants", en=u"German beginners", )) yield courses.Line(**babelkw('name', de=u"Französisch Anfänger", fr=u"Français débutants", en=u"French beginners", ))
def page(ref, language, title, body, parent=None, raw_html=False): if not settings.SITE.get_language_info(language): return pages = dd.resolve_app('pages', strict=True) obj = pages.lookup(ref, None) #~ obj = PAGES.get(ref) if parent is not None: parent = pages.lookup(parent) if obj is None: #~ kw = dict(,parent=parent) obj = pages.create_page(ref=ref) #~ PAGES[ref] = obj #~ if not ref: #~ logger.info("20130109 define index page %r --> %r",language,body) #~ else: #~ if not ref: #~ logger.info("20130109 override index page %r --> %r",language,body) setattr(obj, 'raw_html', raw_html) setattr(obj, 'parent', parent) setattr(obj, babelfield('title', language), title) setattr(obj, babelfield('body', language), body.strip()) # must save it already here so that subsequent pages of the same fixture # can use it as parent. obj.full_clean() obj.save()
def resolve_name(name): l = name.split('.') if len(l) == 1: return 1, dd.resolve_app(name) if len(l) == 3: model = settings.SITE.modules.resolve(l[0]+'.'+l[1]) return 3, model.get_data_elem(l[2]) return len(l), settings.SITE.modules.resolve(name)
def setup_menu(self, ui, profile, main): """ We create a new menu from scratch because the default menu structure wouldn't fit. """ from django.utils.translation import ugettext_lazy as _ from lino import dd, rt concepts = dd.resolve_app('concepts') m = main.add_menu("concepts", concepts.MODULE_LABEL) m.add_action(self.modules.concepts.Concepts) m.add_action(self.modules.countries.Countries) m.add_action(self.modules.countries.Places)
def objects(): ledger = dd.resolve_app('ledger') finan = dd.resolve_app('finan') #~ partners = dd.resolve_app('partners') #~ contacts = dd.resolve_app('contacts') MODEL = finan.BankStatement vt = ledger.VoucherTypes.get_for_model(MODEL) JOURNALS = Cycler(vt.get_journals()) PARTNERS = Cycler(Partner.objects.order_by('name')) USERS = Cycler(settings.SITE.user_model.objects.all()) AMOUNTS = Cycler([Decimal(x) for x in "2.50 6.80 9.95 14.50 20 29.90 39.90 39.90 99.95 199.95 599.95 1599.99".split()]) ITEMCOUNT = Cycler(1,3,10) for i in range(2): jnl = JOURNALS.pop() voucher = MODEL(journal=jnl, user=USERS.pop(), date=settings.SITE.demo_date(-30+i)) yield voucher ACCOUNTS = Cycler(jnl.get_allowed_accounts()) for j in range(ITEMCOUNT.pop()): item = voucher.add_voucher_item( partner=PARTNERS.pop(), account=ACCOUNTS.pop(), amount=AMOUNTS.pop() ) #~ item.total_incl_changed(REQUEST) #~ item.before_ui_save(REQUEST) #~ if item.total_incl: #~ print "20121208 ok", item #~ else: #~ if item.product.price: #~ raise Exception("20121208") yield item voucher.register(REQUEST) yield voucher
def run_from_ui(self, ar, **kw): obj = ar.selected_rows[0] notes = dd.resolve_app('notes') ekw = dict(project=obj, user=ar.get_user()) ekw.update(type=ar.action_param_values.note_type) ekw.update(date=datetime.date.today()) if ar.action_param_values.subject: ekw.update(subject=ar.action_param_values.subject) note = notes.Note(**ekw) note.save() #~ kw.update(success=True) #~ kw.update(refresh=True) ar.goto_instance(note, **kw)
def get_pages_urls(): pages = dd.resolve_app('pages') class PagesIndex(View): def get(self, request,ref='index'): if not ref: ref = 'index' #~ print 20121220, ref obj = pages.lookup(ref,None) if obj is None: raise http.Http404("Unknown page %r" % ref) html = pages.render_node(request,obj) return http.HttpResponse(html) return patterns('', (r'^(?P<ref>\w*)$', PagesIndex.as_view()), )
def objects(): ptype = Instantiator('properties.PropType').build properties = dd.resolve_app('properties') yield ptype(id=1, **babel_values('name', **dict( en="Present or not", de=u"Vorhanden oder nicht", fr=u"Présent ou pas", et=u"Olemas või mitte", nl=u"Ja of niet", ))) yield ptype(id=2, choicelist=properties.HowWell.actor_id, default_value=properties.HowWell.default.value, **babel_values('name', **dict( en="Rating", de=u"Bewertung", et=u"Hinnang", fr=u"Appréciation(?)", nl=u"Hoe goed", )))
def objects(): countries = dd.resolve_app('countries') city = Instantiator(countries.Place, "zip_code name", country='BE', type=countries.PlaceTypes.city).build for ln in belgian_cities.splitlines(): ln = ln.strip() if ln and ln[0] != '#': args = ln.split(None, 1) o = city(*args) # print "%r %r" % (o.zip_code, o.name) yield o #~ print __name__, "20121114" #~ return for ln in belgian_cities_nl_fr.splitlines(): ln = ln.strip() if ln and ln[0] != '#': args = ln.split('|') if len(args) != 4: raise Exception("Invalid format : \n%s" % ln) args = [x.strip() for x in args] o = city(zip_code=args[0], **babel_values('name', nl=args[1], fr=args[2], de=args[3], en=args[3])) yield o
from lino import dd #~ from lino import reports from lino.core import actions from lino import mixins from lino.utils import mti #~ from lino.utils.quantities import Duration from ..vat.utils import add_vat, remove_vat #~ journals = resolve_app('journals') #~ journals = models.get_app('journals') #~ auth = resolve_app('auth') #~ from lino.modlib.users import models as auth partners = dd.resolve_app(settings.SITE.partners_app_label) #~ accounts = dd.resolve_app('accounts') ledger = dd.resolve_app('ledger',strict=True) vat = dd.resolve_app('vat',strict=True) products = dd.resolve_app('products',strict=True) vat.TradeTypes.sales.update( price_field_name='sales_price', price_field_label=_("Sales price"), base_account_field_name='sales_account', base_account_field_label=_("Sales Base account"), vat_account_field_name='sales_vat_account', vat_account_field_label=_("Sales VAT account"), partner_account_field_name='clients_account',
ONE_DAY = relativedelta(days=1) from django.db import models from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.utils.translation import ugettext as _ from lino.utils import i2d from lino.utils.instantiator import Instantiator from lino.core.dbutils import resolve_model from north.dbutils import babel_values from lino import dd cal = dd.resolve_app("cal") def objects(): # ~ add = Instantiator('cal.EventStatus','ref').build # ~ yield add('0',**babel_values('name',en=u"tentative",de=u"Vorschlag", fr=u"proposition")) # ~ yield add('1',**babel_values('name',en=u"confirmed",de=u"bestätigt", fr=u"confirmé")) # ~ yield add('2',**babel_values('name',en=u"cancelled",de=u"storniert", fr=u"annulé")) # ~ yield add('3',**babel_values('name',en=u"rescheduled",de=u"verschoben", fr=u"reporté")) # ~ yield add('4',**babel_values('name',en=u"absent",de=u"abwesend", fr=u"absent")) # ~ add = Instantiator('cal.TaskStatus','ref').build # ~ yield add('0',**babel_values('name',en=u"needs action",de=u"zu erledigen", fr=u"à traîter")) # ~ yield add('1',**babel_values('name',en=u"in process",de=u"begonnen", fr=u"commencée")) # ~ yield add('2',**babel_values('name',en=u"completed",de=u"erledigt", fr=u"complétée"))
def objects(): #~ dblogger.info("Installing countries few_cities fixture") countries = dd.resolve_app('countries') #~ Place = resolve_model('countries.Place') Place = countries.Place Country = countries.Country PlaceTypes = countries.PlaceTypes city = Instantiator(Place, 'name country').build def make_city(country_id, name=None, **kw): kw.setdefault('type', PlaceTypes.city) flt = dbutils.lookup_filter( 'name', name, country__isocode=country_id, **kw) if name == "Rapla" and kw['type'].name == 'county': logger.info("20140611 fld is %s", flt) try: return Place.objects.get(flt) # return Place.objects.exclude(type__in=[ # PlaceTypes.county, PlaceTypes.province]).get(flt) except MultipleObjectsReturned: #~ qs = Place.objects.exclude(type=PlaceTypes.county).filter(country__isocode=country_id,name=name) raise Exception("Oops, there are multiple cities for %r", name) except Place.DoesNotExist: obj = city(name, country_id, **kw) obj.full_clean() obj.save() if name == "Rapla" and kw['type'].name == 'county': logger.info("20140611 DoesNotExist --> %s", obj) return obj BE = Country.objects.get(pk='BE') DE = Country.objects.get(pk='DE') FR = Country.objects.get(pk='FR') eupen = make_city('BE', 'Eupen', zip_code='4700') yield eupen yield make_city('BE', 'Nispert', type=PlaceTypes.township, parent=eupen) reuland = make_city('BE', 'Burg-Reuland ', zip_code='4790') yield make_city('BE', 'Ouren', type=PlaceTypes.township, parent=reuland) yield Place(country=BE, zip_code='4720', type=PlaceTypes.city, **babel_values('name', de='Kelmis', fr='La Calamine', en="Kelmis")) yield make_city('BE', 'Kettenis', zip_code='4701', type=PlaceTypes.village) yield make_city('BE', 'Raeren', zip_code='4730', type=PlaceTypes.village) yield make_city('BE', 'Angleur', zip_code='4031') yield make_city('BE', 'Ans', zip_code='4430') yield make_city('BE', 'Ottignies', zip_code='1340') yield make_city('BE', 'Thieusies', zip_code='7061') yield make_city('BE', 'Cuesmes', zip_code='7033') yield make_city('BE', 'La Reid', zip_code='4910') yield make_city('BE', 'Blégny ', zip_code='4670') yield make_city('BE', 'Trembleur ', zip_code='4670') yield make_city('BE', 'Mortier ', zip_code='4670') yield make_city('BE', 'Cerfontaine', zip_code='5630') yield make_city('BE', 'Burdinne', zip_code='4210') def be_province(de, fr, nl): return Place(country=BE, type=PlaceTypes.province, **babel_values('name', de=de, fr=fr, nl=nl, en=fr)) def be_city(zip_code, de=None, fr=None, nl=None, en=None, **kw): kw.update(babel_values('name', de=de, fr=fr, nl=nl, en=en)) kw.setdefault('type', PlaceTypes.city) return Place(country=BE, zip_code=zip_code, **kw) yield be_province("Antwerpen", "Anvers", "Antwerpen") yield be_province("Luxemburg", "Luxembourg", "Luxemburg") yield be_province("Namür", "Namur", "Namen") prov = be_province("Limburg", "Limbourg", "Limburg") yield prov yield make_city('BE', 'Aalst-bij-Sint-Truiden', zip_code='3800', parent=prov, type=PlaceTypes.village) prov = be_province("Lüttich", "Liège", "Luik") yield prov yield be_city('4000', "Lüttich", "Liège", "Luik", "Liège", parent=prov) yield be_city('4750', "Bütgenbach", "Butgenbach", "Butgenbach", "Butgenbach", parent=prov) yield be_city('4760', "Büllingen", "Bullange", "Büllingen", "Büllingen", parent=prov) yield be_city('4780', "Sankt Vith", "Saint-Vith", "Sankt Vith", "Sankt Vith", parent=prov) yield be_city('4780', "Recht", "Recht", "Recht", "Recht", parent=prov) yield be_city('4837', "Baelen", "Baelen", "Baelen", "Baelen", parent=prov) yield be_province("Hennegau", "Hainaut", "Henegouwen") yield be_province("Wallonisch-Brabant", "Brabant wallon", "Waals-Brabant") yield be_province("Flämisch-Brabant", "Brabant flamant", "Vlaams-Brabant") prov = be_province("Ostflandern", "Flandre de l'Est", "Oost-Vlaanderen") yield prov aalst = be_city('9300', "Aalst", "Alost", "Aalst", "Aalst", parent=prov) yield aalst yield be_city('9308', name="Gijzegem", parent=aalst, type=PlaceTypes.village) yield be_city('9310', name="Baardegem ", parent=aalst, type=PlaceTypes.village) yield be_city('9320', name="Erembodegem", parent=aalst, type=PlaceTypes.village) yield be_city('9310', name="Herdersem", parent=aalst, type=PlaceTypes.village) yield be_city('9308', name="Hofstade", parent=aalst, type=PlaceTypes.village) yield be_city('9310', name="Meldert", parent=aalst, type=PlaceTypes.village) yield be_city('9320', name="Nieuwerkerken", parent=aalst, type=PlaceTypes.village) yield be_city('9310', name="Moorsel", parent=aalst, type=PlaceTypes.village) yield be_province("Westflandern", "Flandre de l'Ouest", "West-Vlaanderen") yield be_city('1000', "Brüssel", "Bruxelles", "Brussel", "Brussels") yield be_city('7000', "Bergen", "Mons", "Bergen", "Mons") yield be_city('8400', "Ostende", "Ostende", "Oostende", "Ostende") yield be_city('5000', "Namür", "Namur", "Namen", "Namur") harjumaa = make_city('EE', 'Harju', type=PlaceTypes.county) yield harjumaa parnumaa = make_city('EE', 'Pärnu', type=PlaceTypes.county) yield parnumaa raplamaa = make_city('EE', 'Rapla', type=PlaceTypes.county) yield raplamaa yield make_city('EE', 'Vigala', type=PlaceTypes.municipality, parent=raplamaa) yield make_city('EE', 'Rapla', type=PlaceTypes.town, parent=raplamaa) yield make_city('EE', 'Tallinn', type=PlaceTypes.city, parent=harjumaa) yield make_city('EE', 'Pärnu', type=PlaceTypes.town, parent=parnumaa) yield make_city('EE', 'Tartu', type=PlaceTypes.town) yield make_city('EE', 'Narva', type=PlaceTypes.town) yield make_city('EE', 'Ääsmäe', type=PlaceTypes.town, parent=harjumaa) #~ yield make_city(u'Aachen','DE') yield Place(country=DE, type=PlaceTypes.city, **babel_values('name', de='Aachen', fr='Aix-la-Chapelle', nl="Aken", en="Aachen")) yield Place(country=DE, type=PlaceTypes.city, **babel_values('name', de='Köln', fr='Cologne', nl="Keulen", en="Cologne")) yield make_city('DE', 'Berlin') yield make_city('DE', 'Hamburg') yield Place(country=DE, type=PlaceTypes.city, **babel_values('name', de='München', fr='Munich', en="Munich")) yield Place(country=DE, type=PlaceTypes.city, **babel_values('name', de='Monschau', fr='Montjoie', en="Monschau")) yield make_city('NL', 'Maastricht') yield make_city('NL', 'Amsterdam') yield make_city('NL', 'Den Haag') yield make_city('NL', 'Rotterdam') yield make_city('NL', 'Utrecht') yield make_city('NL', 'Breda') yield Place(country=FR, type=PlaceTypes.city, **babel_values('name', de='Paris', fr='Paris', en="Paris", et="Pariis", nl="Parijs")) yield Place(country=FR, type=PlaceTypes.city, **babel_values('name', de='Nizza', fr='Nice', en="Nice")) yield make_city('FR', 'Metz') yield make_city('FR', 'Strasbourg') yield make_city('FR', 'Nancy') yield make_city('FR', 'Marseille')
## Copyright 2013 Luc Saffre ## This file is part of the Lino project. import datetime from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _ from lino import dd contacts = dd.resolve_app('contacts') class EntryType(dd.BabelNamed): class Meta: verbose_name = _("Entry Type") verbose_name_plural = _("Entry Types") #~ def after_ui_save(self,ar): #~ CompaniesWithEntryTypes.setup_columns() class EntryTypes(dd.Table): model = EntryType class Entry(dd.UserAuthored): class Meta: verbose_name = _("Entry") verbose_name_plural = _("Entries")
# You should have received a copy of the GNU Lesser General Public License # along with Lino; if not, see <http://www.gnu.org/licenses/>. from django.db import models from django.utils.translation import ugettext_lazy as _ from lino import dd from lino import mixins # ~ from lino.models import SiteConfig # ~ from lino.modlib.contacts import models as contacts # ~ from lino.modlib.cal import models as cal contacts = dd.resolve_app("contacts") # ~ cal = dd.resolve_app('cal') # ~ school = dd.resolve_app('school') class School(contacts.Company): class Meta: # ~ app_label = 'school' verbose_name = _("School") verbose_name_plural = _("Schools") class Schools(contacts.Companies): model = School
# ~ from lino.utils.choicelists import ChoiceList # contacts = reports.get_app('contacts') # ~ from lino.modlib.journals import models as journals # ~ journals = reports.get_app('journals') # from lino.modlib.contacts import models as contacts # from lino.modlib.journals import models as journals from django.utils.translation import ugettext_lazy as _ # ~ from lino.modlib.accounts.utils import AccountTypes from lino.modlib.ledger.utils import FiscalYears # ~ from lino.core.dbutils import models_by_base partner_model = settings.SITE.partners_app_label + ".Partner" vat = dd.resolve_app("vat") ledger = dd.resolve_app("ledger") ZERO = Decimal() class DeclarationStates(dd.Workflow): pass add = DeclarationStates.add_item add("00", _("Draft"), "draft", editable=True) add("10", _("Registered"), "registered", editable=False) add("20", _("Submitted"), "submitted", editable=False)
import logging logger = logging.getLogger(__name__) from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _ from django.utils.translation import string_concat # from django.utils.encoding import force_unicode from lino import dd, rt from lino import mixins from lino.utils.xmlgen.html import E from lino.utils import join_elems system = dd.resolve_app('system') class UploadAreas(dd.ChoiceList): verbose_name = _("Upload Area") verbose_name_plural = _("Upload Areas") add = UploadAreas.add_item add('90', _("Uploads"), 'general') class UploadType(dd.BabelNamed): """The type of an upload.""" class Meta: abstract = dd.is_abstract_model(__name__, 'UploadType') verbose_name = _("Upload Type") verbose_name_plural = _("Upload Types")
from lino import mixins from lino import dd from .utils import Recurrencies, when_text, AccessClasses from .mixins import Ended from .mixins import RecurrenceSet, EventGenerator from .mixins import UpdateEvents from .mixins import MoveEventNext from .models import Component from .models import Priority from .workflows import EventStates # contacts = dd.resolve_app('contacts') postings = dd.resolve_app("postings") outbox = dd.resolve_app("outbox") def daterange_text(a, b): if a == b: return a.strftime(settings.SITE.date_format_strftime) d = dict(min="...", max="...") if a: d.update(min=a.strftime(settings.SITE.date_format_strftime)) if b: d.update(max=b.strftime(settings.SITE.date_format_strftime)) return _("Dates %(min)s to %(max)s") % d class EventType(dd.BabelNamed, dd.Sequenced, outbox.MailableType):
def card2client(self, data): "does the actual conversion" countries = dd.resolve_app('countries', strict=True) kw = dict() raw_data = data['card_data'] if not '\n' in raw_data: # a one-line string means that some error occured (e.g. no # card in reader). of course we want to show this to the # user. raise Warning(raw_data) #~ print cd data = AttrDict(yaml.load(raw_data)) #~ raise Exception("20131108 cool: %s" % cd) kw.update(national_id=ssin.format_ssin(str(data.nationalNumber))) kw.update(first_name=join_words( data.firstName, data.middleName)) kw.update(last_name=data.name) card_number = str(data.cardNumber) if data.photo: fn = config.card_number_to_picture_file(card_number) if os.path.exists(fn): logger.warning("Overwriting existing image file %s.", fn) fp = file(fn, 'wb') fp.write(base64.b64decode(data.photo)) fp.close() #~ print 20121117, repr(data['picture']) #~ kw.update(picture_data_encoded=data['picture']) if isinstance(data.dateOfBirth, basestring): data.dateOfBirth = IncompleteDate(*data.dateOfBirth.split('-')) kw.update(birth_date=data.dateOfBirth) kw.update(card_valid_from=data.cardValidityDateBegin) kw.update(card_valid_until=data.cardValidityDateEnd) kw.update(card_number=card_number) kw.update(card_issuer=data.cardDeliveryMunicipality) if data.nobleCondition: kw.update(noble_condition=data.nobleCondition) kw.update(street=data.streetAndNumber) #~ kw.update(street_no=data['streetNumber']) #~ kw.update(street_box=data['boxNumber']) if True: # kw['street'] and not (kw['street_no'] or kw['street_box']): kw = street2kw(kw['street'], **kw) kw.update(zip_code=str(data.zip)) if data.placeOfBirth: kw.update(birth_place=data.placeOfBirth) pk = data.reader.upper() msg1 = "BeIdReadCardToClientAction %s" % kw.get('national_id') #~ try: country = countries.Country.objects.get(isocode=pk) kw.update(country=country) #~ except countries.Country.DoesNotExist,e: #~ except Exception,e: #~ logger.warning("%s : no country with code %r",msg1,pk) #~ BE = countries.Country.objects.get(isocode='BE') #~ fld = countries.Place._meta.get_field() kw.update(city=countries.Place.lookup_or_create( 'name', data.municipality, country=country)) def sex2gender(sex): if sex == 'MALE': return dd.Genders.male if sex == 'FEMALE': return dd.Genders.female logger.warning("%s : invalid gender code %r", msg1, sex) kw.update(gender=sex2gender(data.gender)) def doctype2cardtype(dt): #~ if dt == 1: return BeIdCardTypes.get_by_value("1") rv = BeIdCardTypes.get_by_value(str(dt)) # logger.info("20130103 documentType %r --> %r", dt, rv) return rv kw.update(card_type=doctype2cardtype(data.documentType)) if config.data_collector_dir: fn = os.path.join( config.data_collector_dir, card_number + '.txt') file(fn, "w").write(raw_data) logger.info("Wrote eid card data to file %s", fn) return kw
from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic #~ import lino #~ logger.debug(__file__+' : started') from lino import dd from lino import mixins #~ from lino.modlib.contacts import models as contacts #~ from lino.modlib.cal.models import DurationUnits, update_reminder #~ contacts = dd.resolve_app('contacts') cal = dd.resolve_app('cal') class UploadType(dd.Model): class Meta: verbose_name = _("Upload Type") verbose_name_plural = _("Upload Types") name = models.CharField(max_length=200, verbose_name=_('Name')) def __unicode__(self): return self.name class UploadTypes(dd.Table):
logger = logging.getLogger(__name__) import datetime from decimal import Decimal from django.db import models from django.conf import settings from lino import dd from django.utils.translation import ugettext_lazy as _ # from lino.modlib.ledger.utils import FiscalYears #~ from lino.core.dbutils import models_by_base partner_model = settings.SITE.partners_app_label + '.Partner' vat = dd.resolve_app('vat') ledger = dd.resolve_app('ledger') ZERO = Decimal() class DeclarationStates(dd.Workflow): pass add = DeclarationStates.add_item add("00", _("Draft"), "draft", editable=True) add("10", _("Registered"), "registered", editable=False) add("20", _("Submitted"), "submitted", editable=False) DeclarationStates.registered.add_transition( _("Register"), states='draft submitted')
from lino.core import actors from lino.core import dbtables #~ from lino.core import changes from lino.core import web from lino.core.modeltools import obj2str, obj2unicode from lino.core.modeltools import makedirs_if_missing from lino.ui import requests as ext_requests from lino.ui.extjs3 import ext_elems MAX_ROW_COUNT = 300 E = xghtml.E pages = dd.resolve_app('pages') class HttpResponseDeleted(http.HttpResponse): status_code = 204 def requested_actor(app_label,actor): x = getattr(settings.LINO.modules,app_label) cl = getattr(x,actor) if issubclass(cl,dd.Model): return cl._lino_default_table return cl #~ class Http403(Exception): #~ pass
#~ from django import forms from django.conf import settings #~ from django.contrib.auth import models as auth from django.core.exceptions import ValidationError from django.utils.translation import ugettext_lazy as _ from lino import dd #~ from lino import reports from lino.core import actions from lino import mixins from lino.utils import mti #~ from lino.utils.quantities import Duration contacts = dd.resolve_app('contacts') accounts = dd.resolve_app('accounts') ledger = dd.resolve_app('ledger') vat = dd.resolve_app('vat') products = dd.resolve_app('products') sales = dd.resolve_app('sales') class OrderStates(dd.Workflow): pass add = OrderStates.add_item add('10',_("Draft"),'draft',editable=True) add('20',_("Registered"),'registered',editable=False) add('30',_("Inactive"),'inactive',editable=False)
from .utils import ( Recurrencies, when_text, AccessClasses) from .mixins import Ended from .mixins import RecurrenceSet, EventGenerator from .mixins import UpdateEvents from .mixins import MoveEventNext from .mixins import daterange_text from .models import Component from .models import Priority from .workflows import EventStates postings = dd.resolve_app('postings') outbox = dd.resolve_app('outbox') class EventType(dd.BabelNamed, dd.Sequenced, outbox.MailableType): templates_group = 'cal/Event' class Meta: abstract = dd.is_abstract_model(__name__, 'EventType') verbose_name = _("Event Type") verbose_name_plural = _("Event Types") ordering = ['seqno'] #~ name = models.CharField(_("Name"),max_length=200)
""" Run using:: python manage.py run 0914.py """ if False: # TIMTOWTDI: the following is equivalent from django.conf import settings settings.LINO.startup() root = settings.LINO.user_model.objects.get(username="******") ar = settings.LINO.modules.pcsw.UsersWithClients.request(user=root) print ar.to_rst() else: from lino import dd pcsw = dd.resolve_app("pcsw") User = dd.resolve_model("users.User") root = User.objects.get(username="******") print pcsw.UsersWithClients.request(user=root).to_rst()
""" import cgi import datetime from django.conf import settings from django.db import models from django.utils.translation import ugettext_lazy as _ from django.contrib.contenttypes.models import ContentType from django.utils.encoding import force_unicode from lino import mixins from lino import dd #~ from lino.modlib.cal import models as cal blogs = dd.resolve_app('blogs') from lino.modlib.tickets.utils import TicketStates class ProjectType(mixins.PrintableType, dd.BabelNamed): "Deserves more documentation." templates_group = 'tickets/Project' class Meta: verbose_name = _("Project Type") verbose_name_plural = _('Project Types')
import logging logger = logging.getLogger(__name__) import datetime #~ from datetime import timedelta as delta from dateutil.relativedelta import relativedelta as delta from decimal import Decimal from django.conf import settings from lino.utils import Cycler from north.dbutils import babel_values from lino import dd accounts = dd.resolve_app('accounts') vat = dd.resolve_app('vat') sales = dd.resolve_app('sales') ledger = dd.resolve_app('ledger') finan = dd.resolve_app('finan') declarations = dd.resolve_app('declarations') #~ partners = dd.resolve_app('partners') notes = dd.resolve_app('notes') partner_model = settings.SITE.partners_app_label + '.Partner' current_group = None # from lino.core.requests import BaseRequest REQUEST = settings.SITE.login() # BaseRequest() MORE_THAN_A_MONTH = datetime.timedelta(days=40)
import datetime from decimal import Decimal from django.db import models from django.conf import settings from lino import dd from lino import mixins from django.utils.translation import ugettext_lazy as _ from lino.modlib.ledger.utils import FiscalYears from lino.mixins.printable import model_group from lino.utils.xmlgen.html import E from lino.utils import join_elems accounts = dd.resolve_app('accounts', strict=True) contacts = dd.resolve_app('contacts', strict=True) vat = dd.resolve_app('vat', strict=True) # partner_model = settings.SITE.partners_app_label + '.Partner' partner_model = 'contacts.Partner' ZERO = Decimal(0) vat.TradeTypes.purchases.update( #~ price_field_name='sales_price', #~ price_field_label=_("Sales price"), base_account_field_name='purchases_account', base_account_field_label=_("Purchases Base account"), vat_account_field_name='purchases_vat_account', vat_account_field_label=_("Purchases VAT account"),
from lino.core import actions from lino.utils import AttrDict from lino.utils import ONE_DAY from lino.core import constants from lino.modlib.cal.utils import ( DurationUnits, Recurrencies, setkw, dt2kw, when_text, Weekdays, AccessClasses, CalendarAction) contacts = dd.resolve_app('contacts') postings = dd.resolve_app('postings') outbox = dd.resolve_app('outbox') #~ from .models import StartedSummaryDescription from .mixins import Ended from .models import Component from .models import Priority from .mixins import RecurrenceSet, EventGenerator from .mixins import UpdateReminders from .models_calendar import Calendars from .models_calendar import Subscription
""" import os import cgi import datetime from django.db import models #~ from django.db.models import Q from django.conf import settings from django.utils.translation import ugettext_lazy as _ from lino import mixins from lino import dd concepts = dd.resolve_app('concepts') class Main(concepts.TopLevelConcepts): pass def site_setup(site): site.modules.countries.Places.required = dd.required(auth=False) site.modules.countries.Countries.required = dd.required(auth=False) site.modules.concepts.Concepts.required = dd.required(auth=False) site.modules.countries.Places.set_detail_layout(""" name country inscode parent type id PlacesByPlace
The :xfile:`models.py` module for the :mod:`lino.modlib.rooms` app. """ from __future__ import unicode_literals import logging logger = logging.getLogger(__name__) from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _ from django.utils.translation import pgettext_lazy as pgettext from lino import dd contacts = dd.resolve_app('contacts', strict=True) #~ cal = dd.resolve_app('cal',strict=True) from lino.modlib.cal.utils import Recurrencies from lino.modlib.cal.mixins import Reservation class BookingStates(dd.Workflow): required = dd.required(user_level='admin') add = BookingStates.add_item add('10', _("Draft"), 'draft', editable=True) add('20', _("Option"), 'option', editable=False) add('30', _("Registered"), 'registered', editable=False) add('40', _("Cancelled"), 'cancelled', editable=False)