def get_form_display(self): from camelot.view.forms import Form, structure_to_form if self.form or self.form_display: return structure_to_form(self.form or self.form_display) if self.list_display: return Form(self.list_display) return Form([])
def get_form_display(self): from camelot.view.forms import Form, structure_to_form if self.form_display: return structure_to_form(self.form_display) if self.list_display: return Form( self.get_table().get_fields() ) return Form([])
class Admin(EntityAdmin): verbose_name = 'Faza Activitate' verbose_name_plural = 'Faze Activitati' list_display = ['nume', 'descriere', 'data_inceput', 'data_sfarsit'] form_display = TabForm([('Importante', Form(['nume', 'descriere', 'data_inceput', 'data_sfarsit'])), ('Taskuri', Form(['task']))] )
class Admin(EntityAdmin): verbose_name = 'Activitate' verbose_name_plural = 'Activitati' list_display = ['nume', 'aprobata'] form_display = TabForm([('Importante', Form(['nume', 'coordonator'])), ('Participanti', Form(['membrii'])), ('Resurse', Form(['res_fin', 'res_logistice'])), ('Faze', Form(['faze']))]) field_attributes = dict(ResurseUmane.Admin.field_attributes) form_actions = [RapoarteActivitati()]
class PersonAdmin(Party.Admin): verbose_name = _('Person') verbose_name_plural = _('Persons') list_display = ['first_name', 'last_name', 'email', 'phone'] form_display = TabForm([ (_('Basic'), Form([ HBoxForm([ Form([ WidgetOnlyForm('note'), 'first_name', 'last_name', 'sex', 'email', 'phone', 'fax', 'street1', 'street2', 'city', ]), [ WidgetOnlyForm('picture'), ], ]), 'comment', ], scrollbars=False)), (_('Official'), Form([ 'birthdate', 'social_security_number', 'passport_number', 'passport_expiry_date', 'addresses', 'contact_mechanisms', ], scrollbars=False)), (_('Work'), Form(['employers', 'directed_organizations', 'shares'], scrollbars=False)), (_('Category'), Form([ 'categories', ])), ]) field_attributes = dict(Party.Admin.field_attributes) field_attributes['note'] = {'delegate': delegates.NoteDelegate} def get_query(self): query = super(PersonAdmin, self).get_query() query = query.options(orm.joinedload('contact_mechanisms')) return query
class PartyContactMechanismAdmin( EntityAdmin ): form_size = ( 700, 200 ) verbose_name = _('Contact mechanism') verbose_name_plural = _('Contact mechanisms') list_search = ['party_name', 'mechanism'] list_display = ['party_name', 'contact_mechanism_mechanism', 'comment', 'from_date', ] form_display = Form( ['contact_mechanism_mechanism', 'comment', 'from_date', 'thru_date', ] ) field_attributes = {'party_name':{'minimal_column_width':25, 'editable':False}, 'mechanism':{'minimal_column_width':25,'editable':False}, 'contact_mechanism_mechanism':{'minimal_column_width':25, 'editable':True, 'nullable':False, 'name':_('Mechanism'), 'delegate':delegates.VirtualAddressDelegate}} def flush(self, party_contact_mechanism): if party_contact_mechanism.contact_mechanism: super(PartyContactMechanismAdmin, self).flush( party_contact_mechanism.contact_mechanism ) super(PartyContactMechanismAdmin, self).flush( party_contact_mechanism ) def refresh(self, party_contact_mechanism): if party_contact_mechanism.contact_mechanism: super(PartyContactMechanismAdmin, self).refresh( party_contact_mechanism.contact_mechanism ) super(PartyContactMechanismAdmin, self).refresh( party_contact_mechanism ) party_contact_mechanism._contact_mechanism_mechanism = party_contact_mechanism.mechanism def get_depending_objects(self, contact_mechanism ): party = contact_mechanism.party if party and (party not in Party.query.session.new): party.expire(['email', 'phone']) yield party
class OrganizationAdmin(Party.Admin): verbose_name = _('Organization') verbose_name_plural = _('Organizations') list_display = ['name', 'tax_id', 'email', 'phone', 'fax'] form_display = TabForm([ (_('Basic'), Form([ WidgetOnlyForm('note'), 'name', 'email', 'phone', 'fax', 'tax_id', 'street1', 'street2', 'city', 'addresses', 'contact_mechanisms' ])), (_('Branding'), Form(['logo'])), ]) field_attributes = dict(Party.Admin.field_attributes) def get_query(self): query = super(OrganizationAdmin, self).get_query() query = query.options(orm.joinedload('contact_mechanisms')) return query
class Admin(EntityAdmin): # the list_display attribute specifies which entity attributes should # be visible in the table view list_display = ['cover', 'title', 'releasedate', 'rating',] lines_per_row = 5 # define filters to be available in the table view list_filter = ['genre', list_filter.ComboBoxFilter('director.full_name')] # if the search function needs to look in related object attributes, # those should be specified within list_search list_search = ['director.full_name'] # begin list_actions # # the action buttons that should be available in the list view # list_actions = [ChangeRatingAction()] # end list_actions drop_action = DropAction() # the form_display attribute specifies which entity attributes should be # visible in the form view form_display = TabForm([ ('Movie', Form([ HBoxForm([WidgetOnlyForm('cover'), ['title', 'rating', Stretch()]]), 'short_description', 'releasedate', 'director', 'script', 'genre', 'description',], columns = 2)), ('Cast', WidgetOnlyForm('cast')), ('Visitors', WidgetOnlyForm('visitors_chart')), ('Tags', WidgetOnlyForm('tags')) ]) # begin form_actions # # create a list of actions available for the user on the form view # form_actions = [BurnToDisk()] # end form_actions # # additional attributes for a field can be specified in the # field_attributes dictionary # field_attributes = dict(cast=dict(create_inline=True), genre=dict(choices=genre_choices, editable=lambda o:bool(o.title and len(o.title))), releasedate=dict(background_color=lambda o:ColorScheme.orange_1 if o.releasedate and o.releasedate < datetime.date(1920,1,1) else None), visitors_chart=dict(delegate=delegates.ChartDelegate), rating=dict(tooltip='''<table> <tr><td>1 star</td><td>Not that good</td></tr> <tr><td>2 stars</td><td>Almost good</td></tr> <tr><td>3 stars</td><td>Good</td></tr> <tr><td>4 stars</td><td>Very good</td></tr> <tr><td>5 stars</td><td>Awesome !</td></tr> </table>'''), smiley=dict(delegate=delegates.SmileyDelegate), script=dict(remove_original=True))
class PersonAdmin(Party.Admin): verbose_name = _('Person') verbose_name_plural = _('Persons') list_display = ['first_name', 'last_name', 'email', 'phone'] form_display = TabForm([ (_('Basic'), Form([ HBoxForm([ Form([ WidgetOnlyForm('note'), 'first_name', 'last_name', 'sex', 'email', 'phone', 'fax', 'street1', 'street2', 'city', ]), [WidgetOnlyForm('picture'), Stretch()], ]), 'comment', ], scrollbars=False)), (_('Official'), Form([ 'birthdate', 'social_security_number', 'passport_number', 'passport_expiry_date', 'addresses', 'contact_mechanisms', ], scrollbars=False)), ]) def get_query(self): query = super(PersonAdmin, self).get_query() query = query.options(orm.joinedload('contact_mechanisms')) return query
class Admin(EntityAdmin): form_size = (700, 150) verbose_name = _('Contact mechanism') list_display = ['mechanism'] form_display = Form(['mechanism', 'party_address']) field_attributes = {'mechanism': {'minimal_column_width': 25}} def get_depending_objects(self, contact_mechanism): for party_contact_mechanism in contact_mechanism.party_contact_mechanisms: yield party_contact_mechanism party = party_contact_mechanism.party if party: yield party
class Admin( Party.Admin ): verbose_name = _( 'Organization' ) verbose_name_plural = _( 'Organizations' ) list_display = ['name', 'tax_id', 'contact_mechanisms_email', 'contact_mechanisms_phone'] form_display = TabForm( [( _('Basic'), Form( ['name', 'tax_id', 'addresses', 'contact_mechanisms'] ) ), ( _('Employment'), Form( ['employees'] ) ), ( _('Customers'), Form( ['customers'] ) ), ( _('Suppliers'), Form( ['suppliers'] ) ), ( _('Corporate'), Form( ['directors', 'shareholders', 'shares'] ) ), ( _('Branding'), Form( ['logo'] ) ), ( _('Status'), Form( ['status'] ) ), ] )
class Admin( EntityAdmin ): form_size = ( 700, 150 ) verbose_name = _('Contact mechanism') list_display = ['mechanism'] form_display = Form( ['mechanism', 'party_address'] ) field_attributes = {'mechanism':{'minimal_column_width':25}} def get_depending_objects(self, contact_mechanism ): for party_contact_mechanism in contact_mechanism.party_contact_mechanisms: if party_contact_mechanism not in PartyContactMechanism.query.session.new: party_contact_mechanism.expire( ['mechanism'] ) yield party_contact_mechanism party = party_contact_mechanism.party if party and party not in Party.query.session.new: party.expire(['email', 'phone']) yield party
class PartyContactMechanismAdmin(EntityAdmin): form_size = (700, 200) verbose_name = _('Contact mechanism') verbose_name_plural = _('Contact mechanisms') list_search = ['party_name', 'mechanism'] list_display = [ 'party_name', 'mechanism', 'comment', 'from_date', ] form_display = Form([ 'mechanism', 'comment', 'from_date', 'thru_date', ]) field_attributes = { 'party_name': { 'minimal_column_width': 25, 'editable': False }, 'comment': { 'name': _('Comment') }, 'mechanism': { 'minimal_column_width': 25, 'editable': True, 'nullable': False, 'name': _('Mechanism'), 'delegate': delegates.VirtualAddressDelegate } } def get_depending_objects(self, contact_mechanism): party = contact_mechanism.party if party and (party not in Party.query.session.new): yield party def get_compounding_objects(self, contact_mechanism): if contact_mechanism.contact_mechanism: yield contact_mechanism.contact_mechanism
class Admin( Party.Admin ): verbose_name = _( 'Person' ) verbose_name_plural = _( 'Persons' ) list_display = ['first_name', 'last_name', 'contact_mechanisms_email', 'contact_mechanisms_phone'] form_display = TabForm( [( _('Basic'), Form( [HBoxForm( [Form( [WidgetOnlyForm('note'), 'first_name', 'last_name', 'sex'] ), Form( ['picture', ] ), ] ), 'contact_mechanisms', 'comment', ], scrollbars = False ) ), ( _('Official'), Form( ['birthdate', 'social_security_number', 'passport_number', 'passport_expiry_date', 'addresses', ], scrollbars = False ) ), ( _('Work'), Form( ['employers', 'directed_organizations', 'shares'], scrollbars = False ) ), ( _('Status'), Form( ['status'] ) ), ] ) field_attributes = dict( Party.Admin.field_attributes ) field_attributes['note'] = {'delegate':delegates.NoteDelegate}
class Admin(PagoAdminBase): verbose_name = 'Pago' list_display = [ 'beneficiaria', 'nro_credito', 'fecha', 'monto', 'asistencia', 'barrio', ] list_filter = [ ValidDateFilter('fecha', 'fecha', 'Fecha', default=lambda: ''), ComboBoxFilter('barrio'), ] form_size = (600, 200) field_attributes = dict(beneficiaria=dict(minimal_column_width=25), nro_credito=dict(name=u'Nro. Crédito')) form_display = Form( [HBoxForm([[ 'credito', 'fecha', 'monto', 'asistencia', ]])])
class OrganizationAdmin(Party.Admin): verbose_name = _('Organization') verbose_name_plural = _('Organizations') list_display = ['name', 'tax_id', 'email', 'phone', 'fax'] form_display = TabForm([ (_('Basic'), Form([ 'name', 'email', 'phone', 'fax', 'tax_id', 'street1', 'street2', 'city', 'addresses', 'contact_mechanisms' ])), (_('Employment'), Form(['employees'])), (_('Customers'), Form(['customers'])), (_('Suppliers'), Form(['suppliers'])), (_('Corporate'), Form(['directors', 'shareholders', 'shares'])), (_('Branding'), Form(['logo'])), (_('Category and Status'), Form(['categories', 'status'])), ]) field_attributes = dict(Party.Admin.field_attributes) def get_query(self): query = super(OrganizationAdmin, self).get_query() query = query.options(orm.joinedload('contact_mechanisms')) return query
class Admin(EntityAdmin): verbose_name = 'Beneficiaria' delete_mode = 'on_confirm' list_columns_frozen = 1 lines_per_row = 1 # lo especifico por la foto delete_mode = 'on_confirm' list_display = [ 'nombre', 'apellido', 'grupo', 'fecha_alta', '_activa', 'fecha_baja', 'comentarios', 'dni', 'fecha_nac', 'domicilio', 'estado_civil', 'telefono', 'email', 'barrio', ] form_display = TabForm([ ('Beneficiaria', Form([ HBoxForm([[ 'nombre', 'apellido', 'barrio', 'grupo', '_activa', 'fecha_alta', 'fecha_baja', 'comentarios', 'dni', 'fecha_nac', ], [ WidgetOnlyForm('foto'), 'estado_civil', 'domicilio', 'telefono', 'email', 'creditos_activos' ]]) ])), (u'Créditos', WidgetOnlyForm('creditos')), ]) list_filter = [ GroupBoxFilter('activa', default=True), ComboBoxFilter('barrio.nombre'), ] search_all_fields = False list_search = [ 'id', 'nombre_completo', 'comentarios', 'dni', 'grupo', 'barrio.nombre', ] expanded_list_search = [ 'nombre', 'apellido', 'grupo', 'fecha_alta', 'fecha_baja', 'comentarios', 'dni', 'fecha_nac', 'barrio.nombre', ] field_attributes = dict( fecha_alta=dict(name='Fecha Alta'), _activa=dict( name='Activa', delegate=BoolDelegate, # to_string = lambda x:{True:'Si', False:'No'}[x], # TODO no lo toma editable=True, tooltip= u'No se puede dar de baja una beneficiaria si tiene créditos activos.' ), fecha_baja=dict( name='Fecha Baja', tooltip= u'Al desactivar la beneficiaria, este campo toma la última fecha de pago' ), dni=dict(name='DNI'), fecha_nac=dict(name='Fecha Nac.'), estado_civil=dict(name='Estado Civil'), telefono=dict(name=u'Teléfono'), email=dict(address_type='email'), creditos=dict(admin=CreditoAdminEmbedded), creditos_activos=dict(name=u'Créditos activos', editable=False), ) form_size = (850, 400)
pagos=dict(admin=PagoAdminEmbedded, #create_inline = True, # no funciona como se espera ), # TODO por el momento el name es estatico, no se puede cambiar en funcion de otros valores # monto_cheque = dict(name = lambda o: 'Monto Presupuesto' if o.rubro.actividad.id == ID_ACTIVIDAD_CONSTRUCCION else 'Monto Cheque'), ) form_display = TabForm([ (u'Crédito', Form([ HBoxForm([[ 'beneficiaria', 'rubro', 'cartera', 'nro_credito', 'cuotas' ]]), HBoxForm([[ '_fecha_entrega', 'fecha_cobro', '_prestamo', '_saldo_anterior', 'monto_cheque' ], [ '_tasa_interes', 'deuda_total', 'fecha_finalizacion', 'comentarios', 'gastos_arq' ]]) ])), (u'Pagos', Form([WidgetOnlyForm('pagos'), 'deuda_total', 'total_pagos', 'saldo'])), ]) form_actions = [ reports.ContratoMutuo(), reports.PlanillaPagos(), ]