contatti_app
parent
fb86d21623
commit
3fc0f7ae2b
|
|
@ -8,13 +8,16 @@ from dati_geo_app.admin import RicercaOrdinataMixin, AjaxAutocompleteListFilterM
|
|||
|
||||
# Modified version of a GIST I found in a SO thread
|
||||
# cfr. http://masnun.rocks/2017/03/20/django-admin-expensive-count-all-queries/
|
||||
|
||||
|
||||
class CachingPaginator(Paginator):
|
||||
def _get_count(self):
|
||||
if not hasattr(self, "_count"):
|
||||
self._count = None
|
||||
if self._count is None:
|
||||
try:
|
||||
key = "adm:{0}:count".format(hash(self.object_list.query.__str__()))
|
||||
key = "adm:{0}:count".format(
|
||||
hash(self.object_list.query.__str__()))
|
||||
self._count = cache.get(key, -1)
|
||||
if self._count == -1:
|
||||
self._count = super().count
|
||||
|
|
@ -47,6 +50,15 @@ class PersonaContattoAziendaAdmin(ImportExportModelAdmin):
|
|||
pass
|
||||
|
||||
|
||||
@admin.register(models.VoceContattoRubrica)
|
||||
class VoceContattoRubricaAdmin(ImportExportModelAdmin):
|
||||
# resource = resources.VoceContattoRubricaResource
|
||||
# list_per_page = 15
|
||||
# paginator = CachingPaginator
|
||||
# show_full_result_count = False
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(models.Telefono)
|
||||
class TelefonoAdmin(ImportExportModelAdmin):
|
||||
# resource = resources.TelefonoResource
|
||||
|
|
@ -110,34 +122,28 @@ class PecAdmin(ImportExportModelAdmin):
|
|||
pass
|
||||
|
||||
|
||||
@admin.register(models.SoggettoContattabile)
|
||||
class SoggettoContattabileAdmin(ImportExportModelAdmin):
|
||||
# resource = resources.SoggettoContattabileResource
|
||||
# list_per_page = 15
|
||||
# paginator = CachingPaginator
|
||||
# show_full_result_count = False
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(models.Indirizzo)
|
||||
class IndirizzoAdmin(RicercaOrdinataMixin, AjaxAutocompleteListFilterModelAdmin):
|
||||
list_per_page = 15
|
||||
paginator = CachingPaginator
|
||||
show_full_result_count = False
|
||||
fields=('dug','duf','civico','cap','comune','altro',)
|
||||
search_fields = ('indirizzo','cap_id__exact',)
|
||||
autocomplete_fields = ('dug','cap','comune',)
|
||||
list_display = ('indirizzo', 'cap','comune','provincia','regione',)
|
||||
ordering = ('comune_id','duf','civico',)
|
||||
autocomplete_list_filter = ('comune',)
|
||||
list_filter = ('comune__provincia__regione_id',)
|
||||
class IndirizzoAdmin(ImportExportModelAdmin):
|
||||
# resource = resources.IndirizzoResource
|
||||
# list_per_page = 15
|
||||
# paginator = CachingPaginator
|
||||
# show_full_result_count = False
|
||||
pass
|
||||
|
||||
def get_queryset(self, request):
|
||||
queryset = super().get_queryset(request).select_related('comune__provincia__regione').annotate(indirizzo=Concat('dug_id',Value(' '),'duf',Value(' '),'civico'))
|
||||
return queryset
|
||||
|
||||
def provincia(self, obj):
|
||||
return obj.comune.provincia
|
||||
provincia.short_description = 'Provincia'
|
||||
provincia.admin_order_field = 'comune__provincia_id'
|
||||
|
||||
def regione(self, obj):
|
||||
return obj.comune.provincia.regione_id
|
||||
regione.short_description = 'Regione'
|
||||
regione.admin_order_field = 'comune__provincia__regione_id'
|
||||
|
||||
def indirizzo(self, obj):
|
||||
return obj.indirizzo
|
||||
indirizzo.short_description = 'Indirizzo'
|
||||
indirizzo.admin_order_field = ('comune_id','duf','civico',)
|
||||
@admin.register(models.Societa)
|
||||
class SocietaAdmin(ImportExportModelAdmin):
|
||||
# resource = resources.SocietaResource
|
||||
# list_per_page = 15
|
||||
# paginator = CachingPaginator
|
||||
# show_full_result_count = False
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.1.7 on 2023-05-14 15:43
|
||||
# Generated by Django 4.1.7 on 2023-05-14 22:57
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -25,7 +25,6 @@ class Migration(migrations.Migration):
|
|||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("rimosso", models.BooleanField(blank=True, null=True)),
|
||||
(
|
||||
"polymorphic_ctype",
|
||||
models.ForeignKey(
|
||||
|
|
@ -93,7 +92,7 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
),
|
||||
("indirizzo_email", models.CharField(max_length=30)),
|
||||
("note", models.CharField(max_length=64, null=True)),
|
||||
("note", models.CharField(blank=True, default="", max_length=64)),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "email",
|
||||
|
|
@ -115,8 +114,8 @@ class Migration(migrations.Migration):
|
|||
to="contatti_app.vocecontattorubrica",
|
||||
),
|
||||
),
|
||||
("numero", models.CharField(max_length=20, null=True)),
|
||||
("note", models.CharField(max_length=64, null=True)),
|
||||
("numero", models.CharField(max_length=20)),
|
||||
("note", models.CharField(blank=True, default="", max_length=64)),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "fax",
|
||||
|
|
@ -209,9 +208,10 @@ class Migration(migrations.Migration):
|
|||
to="contatti_app.soggettocontattabile",
|
||||
),
|
||||
),
|
||||
("titolo", models.CharField(max_length=10, null=True)),
|
||||
("nome", models.CharField(max_length=60, null=True)),
|
||||
("cognome", models.CharField(max_length=60, null=True)),
|
||||
("titolo", models.CharField(blank=True, default="", max_length=10)),
|
||||
("nome", models.CharField(max_length=60)),
|
||||
("cognome", models.CharField(max_length=60)),
|
||||
("is_privato", models.BooleanField(default=True)),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "persona fisica",
|
||||
|
|
@ -233,7 +233,7 @@ class Migration(migrations.Migration):
|
|||
to="contatti_app.soggettocontattabile",
|
||||
),
|
||||
),
|
||||
("denominazione", models.CharField(max_length=80, null=True)),
|
||||
("denominazione", models.CharField(max_length=80)),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "persona giuridica",
|
||||
|
|
@ -256,8 +256,8 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
),
|
||||
("numero", models.CharField(max_length=20)),
|
||||
("interno", models.CharField(max_length=20, null=True)),
|
||||
("note", models.CharField(max_length=64, null=True)),
|
||||
("interno", models.CharField(blank=True, default="", max_length=20)),
|
||||
("note", models.CharField(blank=True, default="", max_length=64)),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "telefono",
|
||||
|
|
@ -337,12 +337,10 @@ class Migration(migrations.Migration):
|
|||
to="contatti_app.indirizzo",
|
||||
),
|
||||
),
|
||||
("is_legale", models.BooleanField(blank=True, null=True)),
|
||||
("is_legale", models.BooleanField(default=False)),
|
||||
(
|
||||
"societa",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="sedi",
|
||||
to="contatti_app.societa",
|
||||
|
|
@ -369,12 +367,10 @@ class Migration(migrations.Migration):
|
|||
to="contatti_app.personafisica",
|
||||
),
|
||||
),
|
||||
("is_personale", models.BooleanField(blank=True, null=True)),
|
||||
("is_personale", models.BooleanField(default=True)),
|
||||
(
|
||||
"azienda",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="persone",
|
||||
to="contatti_app.societa",
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
# Generated by Django 4.1.7 on 2023-05-14 16:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("contatti_app", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="personafisica",
|
||||
name="is_privato",
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -42,32 +42,21 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="PersonaFisica" row="soggettocontattabile_ptr" />
|
||||
</row>
|
||||
<row name="azienda" null="1" autoincrement="0">
|
||||
<row name="azienda" null="0" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="is_personale" null="0" autoincrement="0">
|
||||
<datatype>bit</datatype>
|
||||
<default>True</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>personafisica_ptr</part>
|
||||
</key>
|
||||
</table>
|
||||
<table x="559" y="767" name="Nazione">
|
||||
<row name="id" null="1" autoincrement="1">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="codifica" null="0" autoincrement="0">
|
||||
<datatype>CHAR(2)</datatype>
|
||||
<default>'NULL'</default></row>
|
||||
<row name="descrizione" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(250)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>id</part>
|
||||
</key>
|
||||
</table>
|
||||
<table x="2048" y="345" name="VoceContattoRubrica">
|
||||
<row name="id" null="1" autoincrement="1">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="soggetto" null="1" autoincrement="0">
|
||||
<row name="soggetto" null="0" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="SoggettoContattabile" row="id" />
|
||||
</row>
|
||||
|
|
@ -84,7 +73,7 @@
|
|||
<datatype>VARCHAR(20)</datatype>
|
||||
<default>'NULL'</default></row>
|
||||
<row name="interno" null="1" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<datatype>VARCHAR(20)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="note" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(64)</datatype>
|
||||
|
|
@ -98,7 +87,7 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="VoceContattoRubrica" row="id" />
|
||||
</row>
|
||||
<row name="indirizzo" null="0" autoincrement="0">
|
||||
<row name="indirizzo_email" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(30)</datatype>
|
||||
<default>'NULL'</default></row>
|
||||
<row name="note" null="1" autoincrement="0">
|
||||
|
|
@ -116,15 +105,15 @@
|
|||
<row name="titolo" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(10)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="nome" null="1" autoincrement="0">
|
||||
<row name="nome" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(60)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="cognome" null="1" autoincrement="0">
|
||||
<default>'NULL'</default></row>
|
||||
<row name="cognome" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(60)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="is_privato" null="1" autoincrement="0">
|
||||
<default>'NULL'</default></row>
|
||||
<row name="is_privato" null="0" autoincrement="0">
|
||||
<datatype>bit</datatype>
|
||||
<default>NULL</default></row>
|
||||
<default>True</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>soggettocontattabile_ptr</part>
|
||||
</key>
|
||||
|
|
@ -134,9 +123,9 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="SoggettoContattabile" row="id" />
|
||||
</row>
|
||||
<row name="denominazione" null="1" autoincrement="0">
|
||||
<row name="denominazione" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(80)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<default>'NULL'</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>soggettocontattabile_ptr</part>
|
||||
</key>
|
||||
|
|
@ -181,36 +170,6 @@
|
|||
<part>email_ptr</part>
|
||||
</key>
|
||||
</table>
|
||||
<table x="301" y="470" name="AbstractIndirizzo">
|
||||
<row name="id" null="1" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>None</default></row>
|
||||
<row name="duf" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(256)</datatype>
|
||||
<default>'None'</default></row>
|
||||
<row name="civico" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(256)</datatype>
|
||||
<default>'None'</default></row>
|
||||
<row name="altro" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(2048)</datatype>
|
||||
<default>'None'</default></row>
|
||||
<row name="cap_id" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(5)</datatype>
|
||||
<default>'None'</default></row>
|
||||
<row name="comune_id" null="1" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>None</default></row>
|
||||
<row name="dug_id" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(40)</datatype>
|
||||
<default>'None'</default></row>
|
||||
<row name="nazione" null="1" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="Nazione" row="id" />
|
||||
</row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>id</part>
|
||||
</key>
|
||||
</table>
|
||||
<table x="1795" y="486" name="SoggettoContattabile">
|
||||
<row name="id" null="1" autoincrement="1">
|
||||
<datatype>INTEGER</datatype>
|
||||
|
|
@ -222,8 +181,7 @@
|
|||
<table x="2033" y="81" name="Indirizzo">
|
||||
<row name="contattorubrica_ptr" null="1" autoincrement="1">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="AbstractIndirizzo" row="id" />
|
||||
<relation table="VoceContattoRubrica" row="id" />
|
||||
<default>NULL</default><relation table="VoceContattoRubrica" row="id" />
|
||||
</row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>contattorubrica_ptr</part>
|
||||
|
|
@ -236,9 +194,8 @@
|
|||
<default>NULL</default></row>
|
||||
<row name="nazione" null="1" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="Nazione" row="id" />
|
||||
</row>
|
||||
<row name="soggetto" null="1" autoincrement="0">
|
||||
<default>NULL</default></row>
|
||||
<row name="soggetto" null="0" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="SoggettoContattabile" row="id" />
|
||||
</row>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class SoggettoContattabile(PolymorphicModel):
|
|||
verbose_name = 'soggetto contattabile'
|
||||
verbose_name_plural = 'soggetti contattabili'
|
||||
|
||||
rimosso = models.BooleanField(null=True, blank=True)
|
||||
|
||||
class VoceContattoRubrica(PolymorphicModel):
|
||||
class Meta:
|
||||
|
|
@ -39,11 +38,12 @@ class PersonaFisica(SoggettoContattabile):
|
|||
out=f'{self.titolo} {out}'
|
||||
return out
|
||||
|
||||
titolo = models.CharField(null=True, max_length=10)
|
||||
nome = models.CharField(null=True, max_length=60)
|
||||
cognome = models.CharField(null=True, max_length=60)
|
||||
titolo = models.CharField(null=False,blank=True,default='', max_length=10)
|
||||
nome = models.CharField(null=False,blank=False, max_length=60)
|
||||
cognome = models.CharField(null=False,blank=False, max_length=60)
|
||||
is_privato = models.BooleanField(null=False, blank=False, default=True)
|
||||
|
||||
|
||||
class PersonaGiuridica(SoggettoContattabile):
|
||||
class Meta:
|
||||
verbose_name = 'persona giuridica'
|
||||
|
|
@ -58,7 +58,7 @@ class PersonaGiuridica(SoggettoContattabile):
|
|||
out = 'Persona giuridica senza nome #{self.id}'
|
||||
return out
|
||||
|
||||
denominazione = models.CharField(null=True, max_length=80)
|
||||
denominazione = models.CharField(null=False,blank=False, max_length=80)
|
||||
|
||||
|
||||
class Telefono(VoceContattoRubrica):
|
||||
|
|
@ -75,9 +75,9 @@ class Telefono(VoceContattoRubrica):
|
|||
tel += ' (!)'
|
||||
return tel
|
||||
|
||||
numero = models.CharField(max_length=20)
|
||||
interno = models.CharField(null=True, max_length=20)
|
||||
note = models.CharField(null=True, max_length=64)
|
||||
numero = models.CharField(null=False,blank=False,max_length=20)
|
||||
interno = models.CharField(null=False,blank=True,default='', max_length=20)
|
||||
note = models.CharField(null=False,blank=True,default='', max_length=64)
|
||||
|
||||
|
||||
class Email(VoceContattoRubrica):
|
||||
|
|
@ -91,8 +91,8 @@ class Email(VoceContattoRubrica):
|
|||
eml += ' (!)'
|
||||
return eml
|
||||
|
||||
indirizzo_email = models.CharField(max_length=30)
|
||||
note = models.CharField(null=True, max_length=64)
|
||||
indirizzo_email = models.CharField(null=False,blank=False,max_length=30)
|
||||
note = models.CharField(null=False,blank=True,default='', max_length=64)
|
||||
|
||||
|
||||
class Pec(Email):
|
||||
|
|
@ -115,8 +115,8 @@ class Fax(VoceContattoRubrica):
|
|||
out += ' (!)'
|
||||
return out.strip()
|
||||
|
||||
numero = models.CharField(null=True, max_length=20)
|
||||
note = models.CharField(null=True, max_length=64)
|
||||
numero = models.CharField(null=False,blank=False, max_length=20)
|
||||
note = models.CharField(null=False,blank=True,default='', max_length=64)
|
||||
|
||||
class Indirizzo(VoceContattoRubrica, AbstractIndirizzo):
|
||||
class Meta(AbstractIndirizzo.Meta):
|
||||
|
|
@ -132,8 +132,8 @@ class Sede(Indirizzo):
|
|||
return f"Sede (id: {self.id})"
|
||||
|
||||
societa = models.ForeignKey('Societa', on_delete=models.CASCADE,
|
||||
null=True, blank=True, related_name="sedi")
|
||||
is_legale = models.BooleanField(null=True, blank=True)
|
||||
null=False, blank=False, related_name="sedi")
|
||||
is_legale = models.BooleanField(null=False, blank=False, default=False)
|
||||
|
||||
|
||||
class Societa(models.Model):
|
||||
|
|
@ -163,6 +163,6 @@ class PersonaContattoAzienda(PersonaFisica):
|
|||
def __str__(self):
|
||||
return f"PersonaContattoAzienda (id: {self.id})"
|
||||
|
||||
azienda = models.ForeignKey(Societa, on_delete=models.CASCADE, null=True,
|
||||
blank=True, related_name='persone')
|
||||
is_personale = models.BooleanField(null=True, blank=True)
|
||||
azienda = models.ForeignKey(Societa, on_delete=models.CASCADE, null=False,
|
||||
blank=False, related_name='persone')
|
||||
is_personale = models.BooleanField(null=False, blank=False, default=True)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ class PersonaContattoAziendaResource(resources.ModelResource):
|
|||
model = models.PersonaContattoAzienda
|
||||
|
||||
|
||||
class VoceContattoRubricaResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = models.VoceContattoRubrica
|
||||
|
||||
|
||||
class TelefonoResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = models.Telefono
|
||||
|
|
@ -42,3 +47,18 @@ class FaxResource(resources.ModelResource):
|
|||
class PecResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = models.Pec
|
||||
|
||||
|
||||
class SoggettoContattabileResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = models.SoggettoContattabile
|
||||
|
||||
|
||||
class IndirizzoResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = models.Indirizzo
|
||||
|
||||
|
||||
class SocietaResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = models.Societa
|
||||
|
|
|
|||
|
|
@ -7,38 +7,31 @@ from . import models
|
|||
class PersonaContattoAziendaSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.PersonaContattoAzienda
|
||||
fields = ('azienda')
|
||||
fields = ('azienda', 'is_personale')
|
||||
|
||||
|
||||
class SoggettoFiscaleSerializer(serializers.ModelSerializer):
|
||||
class VoceContattoRubricaSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.SoggettoFiscale
|
||||
fields = ('indirizzo_pec', 'sede_legale', 'stabile_organizzazione',
|
||||
'nazione', 'revisione_principale', 'rimosso')
|
||||
|
||||
|
||||
class DatoDiContattoSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.DatoDiContatto
|
||||
fields = ('soggetto_fiscale')
|
||||
model = models.VoceContattoRubrica
|
||||
fields = ('soggetto')
|
||||
|
||||
|
||||
class TelefonoSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.Telefono
|
||||
fields = ('numero', 'note')
|
||||
fields = ('numero', 'interno', 'note')
|
||||
|
||||
|
||||
class EmailSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.Email
|
||||
fields = ('indirizzo', 'note')
|
||||
fields = ('indirizzo_email', 'note')
|
||||
|
||||
|
||||
class PersonaFisicaSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.PersonaFisica
|
||||
fields = ('titolo', 'nome', 'cognome')
|
||||
fields = ('titolo', 'nome', 'cognome', 'is_privato')
|
||||
|
||||
|
||||
class PersonaGiuridicaSerializer(serializers.ModelSerializer):
|
||||
|
|
@ -50,7 +43,7 @@ class PersonaGiuridicaSerializer(serializers.ModelSerializer):
|
|||
class SedeSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.Sede
|
||||
fields = ('inquilino', 'is_legale')
|
||||
fields = ('societa', 'is_legale')
|
||||
|
||||
|
||||
class FaxSerializer(serializers.ModelSerializer):
|
||||
|
|
@ -63,3 +56,21 @@ class PecSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = models.Pec
|
||||
fields = ('')
|
||||
|
||||
|
||||
class SoggettoContattabileSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.SoggettoContattabile
|
||||
fields = ('')
|
||||
|
||||
|
||||
class IndirizzoSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.Indirizzo
|
||||
fields = ('')
|
||||
|
||||
|
||||
class SocietaSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = models.Societa
|
||||
fields = ('nazione', 'soggetto', 'ragione_sociale')
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ router = routers.DefaultRouter()
|
|||
# --------------- FINE PREFISSO TEMPLATE ---------------
|
||||
|
||||
router.register(r'personacontattoazienda', views.PersonaContattoAzienda_View)
|
||||
router.register(r'soggettofiscale', views.SoggettoFiscale_View)
|
||||
router.register(r'datodicontatto', views.DatoDiContatto_View)
|
||||
router.register(r'vocecontattorubrica', views.VoceContattoRubrica_View)
|
||||
router.register(r'telefono', views.Telefono_View)
|
||||
router.register(r'email', views.Email_View)
|
||||
router.register(r'personafisica', views.PersonaFisica_View)
|
||||
|
|
@ -21,5 +20,8 @@ router.register(r'personagiuridica', views.PersonaGiuridica_View)
|
|||
router.register(r'sede', views.Sede_View)
|
||||
router.register(r'fax', views.Fax_View)
|
||||
router.register(r'pec', views.Pec_View)
|
||||
router.register(r'soggettocontattabile', views.SoggettoContattabile_View)
|
||||
router.register(r'indirizzo', views.Indirizzo_View)
|
||||
router.register(r'societa', views.Societa_View)
|
||||
|
||||
urlpatterns += router.urls
|
||||
|
|
|
|||
|
|
@ -27,20 +27,12 @@ class PersonaContattoAzienda_View(viewsets.ModelViewSet):
|
|||
serializer_class = serializers.PersonaContattoAziendaSerializer
|
||||
|
||||
|
||||
class SoggettoFiscale_View(viewsets.ModelViewSet):
|
||||
class VoceContattoRubrica_View(viewsets.ModelViewSet):
|
||||
# authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
|
||||
# permission_classes = [DjangoModelPermissions]
|
||||
|
||||
queryset = models.SoggettoFiscale.objects.all()
|
||||
serializer_class = serializers.SoggettoFiscaleSerializer
|
||||
|
||||
|
||||
class DatoDiContatto_View(viewsets.ModelViewSet):
|
||||
# authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
|
||||
# permission_classes = [DjangoModelPermissions]
|
||||
|
||||
queryset = models.DatoDiContatto.objects.all()
|
||||
serializer_class = serializers.DatoDiContattoSerializer
|
||||
queryset = models.VoceContattoRubrica.objects.all()
|
||||
serializer_class = serializers.VoceContattoRubricaSerializer
|
||||
|
||||
|
||||
class Telefono_View(viewsets.ModelViewSet):
|
||||
|
|
@ -97,3 +89,27 @@ class Pec_View(viewsets.ModelViewSet):
|
|||
|
||||
queryset = models.Pec.objects.all()
|
||||
serializer_class = serializers.PecSerializer
|
||||
|
||||
|
||||
class SoggettoContattabile_View(viewsets.ModelViewSet):
|
||||
# authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
|
||||
# permission_classes = [DjangoModelPermissions]
|
||||
|
||||
queryset = models.SoggettoContattabile.objects.all()
|
||||
serializer_class = serializers.SoggettoContattabileSerializer
|
||||
|
||||
|
||||
class Indirizzo_View(viewsets.ModelViewSet):
|
||||
# authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
|
||||
# permission_classes = [DjangoModelPermissions]
|
||||
|
||||
queryset = models.Indirizzo.objects.all()
|
||||
serializer_class = serializers.IndirizzoSerializer
|
||||
|
||||
|
||||
class Societa_View(viewsets.ModelViewSet):
|
||||
# authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
|
||||
# permission_classes = [DjangoModelPermissions]
|
||||
|
||||
queryset = models.Societa.objects.all()
|
||||
serializer_class = serializers.SocietaSerializer
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.1.7 on 2023-05-14 15:43
|
||||
# Generated by Django 4.1.7 on 2023-05-14 22:58
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -689,7 +689,7 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
),
|
||||
(
|
||||
"sede_legale",
|
||||
"sede",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="SoggettoFiscale_da_Indirizzo",
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
# Generated by Django 4.1.7 on 2023-05-14 16:17
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("fattura_elettronica_app", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name="soggettofiscale",
|
||||
old_name="sede_legale",
|
||||
new_name="sede",
|
||||
),
|
||||
]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.1.7 on 2023-05-14 15:43
|
||||
# Generated by Django 4.1.7 on 2023-05-14 22:58
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -8,8 +8,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("fattura_elettronica_app", "0001_initial"),
|
||||
("contatti_app", "0001_initial"),
|
||||
("fattura_elettronica_app", "__first__"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.1.7 on 2023-05-14 15:43
|
||||
# Generated by Django 4.1.7 on 2023-05-14 22:58
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -8,8 +8,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("offerte_app", "0001_initial"),
|
||||
("fattura_elettronica_app", "0001_initial"),
|
||||
("offerte_app", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
|
|||
|
|
@ -217,9 +217,12 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="PersonaFisica" row="soggettocontattabile_ptr" />
|
||||
</row>
|
||||
<row name="azienda" null="1" autoincrement="0">
|
||||
<row name="azienda" null="0" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="is_personale" null="0" autoincrement="0">
|
||||
<datatype>bit</datatype>
|
||||
<default>True</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>personafisica_ptr</part>
|
||||
</key>
|
||||
|
|
@ -1034,7 +1037,7 @@
|
|||
<row name="id" null="1" autoincrement="1">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="soggetto" null="1" autoincrement="0">
|
||||
<row name="soggetto" null="0" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="SoggettoContattabile" row="id" />
|
||||
</row>
|
||||
|
|
@ -1051,7 +1054,7 @@
|
|||
<datatype>VARCHAR(20)</datatype>
|
||||
<default>'NULL'</default></row>
|
||||
<row name="interno" null="1" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<datatype>VARCHAR(20)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="note" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(64)</datatype>
|
||||
|
|
@ -1065,7 +1068,7 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="VoceContattoRubrica" row="id" />
|
||||
</row>
|
||||
<row name="indirizzo" null="0" autoincrement="0">
|
||||
<row name="indirizzo_email" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(30)</datatype>
|
||||
<default>'NULL'</default></row>
|
||||
<row name="note" null="1" autoincrement="0">
|
||||
|
|
@ -1189,15 +1192,15 @@
|
|||
<row name="titolo" null="1" autoincrement="0">
|
||||
<datatype>VARCHAR(10)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="nome" null="1" autoincrement="0">
|
||||
<row name="nome" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(60)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="cognome" null="1" autoincrement="0">
|
||||
<default>'NULL'</default></row>
|
||||
<row name="cognome" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(60)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<row name="is_privato" null="1" autoincrement="0">
|
||||
<default>'NULL'</default></row>
|
||||
<row name="is_privato" null="0" autoincrement="0">
|
||||
<datatype>bit</datatype>
|
||||
<default>NULL</default></row>
|
||||
<default>True</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>soggettocontattabile_ptr</part>
|
||||
</key>
|
||||
|
|
@ -1207,9 +1210,9 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="SoggettoContattabile" row="id" />
|
||||
</row>
|
||||
<row name="denominazione" null="1" autoincrement="0">
|
||||
<row name="denominazione" null="0" autoincrement="0">
|
||||
<datatype>VARCHAR(80)</datatype>
|
||||
<default>NULL</default></row>
|
||||
<default>'NULL'</default></row>
|
||||
<key type="PRIMARY" name="">
|
||||
<part>soggettocontattabile_ptr</part>
|
||||
</key>
|
||||
|
|
@ -2092,7 +2095,7 @@
|
|||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="Nazione" row="id" />
|
||||
</row>
|
||||
<row name="soggetto" null="1" autoincrement="0">
|
||||
<row name="soggetto" null="0" autoincrement="0">
|
||||
<datatype>INTEGER</datatype>
|
||||
<default>NULL</default><relation table="SoggettoContattabile" row="id" />
|
||||
</row>
|
||||
|
|
|
|||
Loading…
Reference in New Issue