organizations sono tutte le ‘Organization’ attive e non
owner_organizations sono le ‘Organization’ attive titolari del software (category = “com”)
customer_organizations sono le ‘Organization’ attive di tipo cliente (category = “cus”)
supplier_organizations sono le ‘Organization’ attive di tipo fornitori (category = “sup”)
contacts sono tutti i ‘Contact’ attivi e non
owner_contacts sono i ‘Contact’ attivi dipendenti delle ‘Owner Organizations’
customer_contacts sono i ‘Contact’ attivi dipendenti delle ‘Customer Organizations’
supplier_contacts sono i ‘Contact’ attivi dipendenti delle ‘Supplier Organizations’
worker_contacts sono i ‘Contact’ attivi dipendenti delle ‘Owner e Supplier Organizations’
potential_managers sono i ‘Contact’ attivi che possono gestire i progetti e i ticket (owner_contacts)
potential_staff sono i ‘Contact’ attivi che possono lavorare i ticket (worker_contacts)
ticket_projects sono i ‘TicketProject’ attivi e non
active_ticket_projects sono i ‘TicketProject’ attivi e validi
I permessi per l’accesso e la visibilità dei progetti e dei ticket sono regolati da un sistema a vari livelli.
Non è possibile aggiungere ticket se non si hanno i normali permessi di django (add_ticket, change_ticket, ...). Quindi è opportuno creare un gruppo apposito (es.: ticket user).
In aggiunta a questo prerequisito è possibile operare in uno dei 2 seguenti modi:
from django.contrib.auth.models import User users = User.objects.all() [ <User: vittorino>, <User: sandro>, <User: luca>, <User: daniele>, <User: marco>, <User: francesca>, <User: giorgia>, <User: martina>, <User: daniela>, <User: giovanna>, <User: luisa>, <User: chiara>, <User: elena>, <User: paolo>, <User: fabio>, <User: admin> ]
username password SU ST ACT vittorino vitto F T T sandro sandro F T T luca luca F T T daniele daniele F T T marco marco F F F francesca francesca F T T giorgia giorgia F T T martina martina F T T daniela daniela F T T giovanna giovanna F F F luisa luisa F T T chiara chiara F T T elena elena F T T paolo paolo F T T fabio fabio F T T admin admin F T T
from jmb.organization.models import Organization organizations = Organization.objects.all() [ <Organization: Barilla>, <Organization: Cogema>, <Organization: De Cecco>, <Organization: Siex>, <Organization: Thunder Systems>, <Organization: Voiello> ]owner
owner_organizations = Organization.owners.all() [<Organization: Thunder Systems>] thunder = owner_organizations.get(name="Thunder Systems") <Organization: Thunder Systems>customer
customer_organizations = Organization.customers.all() [<Organization: Barilla>, <Organization: De Cecco>, <Organization: Voiello>] barilla = customer_organizations.get(name="Barilla") de_cecco = customer_organizations.get(name="De Cecco") voiello = customer_organizations.get(name="Voiello")supplier
supplier_organizations = Organization.suppliers.all() [<Organization: Cogema>, <Organization: Siex>] siex = supplier_organizations.get(name="Siex") cogema = supplier_organizations.get(name="Cogema")
Name ACT Barilla T Cogema T De Cecco T Siex T Thunder Systems T Voiello T
from jmb.organization.models import Contact contacts = Contact.objects.all() [ <Contact: Sig.a Chiara Chiara (Referente)>, <Contact: Sig.a Daniela Daniela (Referente)>, <Contact: Sig. Daniele Daniele (Sistemista)>, <Contact: Sig.a Elena Elena (Referente)>, <Contact: Sig. Fabio Fabio (Referente)>, <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>, <Contact: Sig.a Giovanna Giovanna (Referente)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Sig.a Luisa Luisa (Referente)>, <Contact: Sig. Marco Marco (Programmatore)>, <Contact: Dott. Martina Martina (Referente)>, <Contact: Sig. Paolo Paolo (Referente)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]owner
owner_contacts = Contact.owners.all() [ <Contact: Sig. Daniele Daniele (Sistemista)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Sig. Marco Marco (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]customer
customer_contacts = Contact.customers.all() [ <Contact: Sig.a Chiara Chiara (Referente)>, <Contact: Sig.a Daniela Daniela (Referente)>, <Contact: Sig.a Elena Elena (Referente)>, <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>, <Contact: Sig.a Giovanna Giovanna (Referente)>, <Contact: Sig.a Luisa Luisa (Referente)>, <Contact: Dott. Martina Martina (Referente)> ]supplier
supplier_contacts = Contact.suppliers.all() [<Contact: Sig. Fabio Fabio (Referente)>, <Contact: Sig. Paolo Paolo (Referente)>]worker
worker_contacts = Contact.workers.all() [ <Contact: Sig. Daniele Daniele (Sistemista)>, <Contact: Sig. Fabio Fabio (Referente)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Sig. Marco Marco (Programmatore)>, <Contact: Sig. Paolo Paolo (Referente)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]
thunder_contacts = thunder.contacts.filter(status=1) [ <Contact: Sig. Daniele Daniele (Sistemista)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Sig. Marco Marco (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]
barilla_contacts = barilla.contacts.filter(status=1) [ <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>, <Contact: Dott. Martina Martina (Referente)> ] de_cecco_contacts = de_cecco.contacts.filter(status=1) [ <Contact: Sig.a Daniela Daniela (Referente)>, <Contact: Sig.a Giovanna Giovanna (Referente)>, <Contact: Sig.a Luisa Luisa (Referente)> ] voiello_contact = voiello.contacts.filter(status=1) [<Contact: Sig.a Chiara Chiara (Referente)>, <Contact: Sig.a Elena Elena (Referente)>]
siex_contacts = siex.contacts.filter(status=1) [<Contact: Sig. Paolo Paolo (Referente)>] cogema_contacts = cogema.contacts.filter(status=1) [<Contact: Sig. Fabio Fabio (Referente)>]
potential_managers = owner_contacts [ <Contact: Sig. Daniele Daniele (Sistemista)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Sig. Marco Marco (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ] potential_staff = worker_contacts [ <Contact: Sig. Daniele Daniele (Sistemista)>, <Contact: Sig. Fabio Fabio (Referente)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Sig. Marco Marco (Programmatore)>, <Contact: Sig. Paolo Paolo (Referente)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ] potential_customers = customer_contacts [ <Contact: Sig.a Chiara Chiara (Referente)>, <Contact: Sig.a Daniela Daniela (Referente)>, <Contact: Sig.a Elena Elena (Referente)>, <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>, <Contact: Sig.a Giovanna Giovanna (Referente)>, <Contact: Sig.a Luisa Luisa (Referente)>, <Contact: Dott. Martina Martina (Referente)> ]
from jmb.ticket.models import TicketProject ticket_projects = TicketProject.objects.all() [ <TicketProject: barilla sw1 (Barilla)>, <TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)>, <TicketProject: de cecco sw (De Cecco)>, <TicketProject: voiello sw (Voiello)> ] active_ticket_projects = TicketProject.active.all() [ <TicketProject: barilla sw1 (Barilla)>, <TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)>, <TicketProject: de cecco sw (De Cecco)>, <TicketProject: voiello sw (Voiello)> ]
name date start date end barilla sw1 2013, 1, 1 2013, 12, 31 barilla sw2 2013, 1, 1 2013, 12, 31 barilla sw3 2013, 1, 1 2013, 12, 31 de cecco sw 2013, 1, 1 2013, 12, 31 voiello sw 2013, 1, 1 2013, 12, 31 barilla
barilla_ticket_projects = active_ticket_projects.filter(organization=barilla) [ <TicketProject: barilla sw1 (Barilla)>, <TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)> ]de cecco
de_cecco_ticket_projects = active_ticket_projects.filter(organization=de_cecco) [<TicketProject: de cecco sw (De Cecco)>]voiello
voiello_ticket_projects = active_ticket_projects.filter(organization=voiello) [<TicketProject: voiello sw (Voiello)>]
barilla
managers
barilla_ticket_managers = potential_managers.filter( managed_ticketprojects__organization=barilla ).distinct() [<Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)>]staff
barilla_ticket_staff = potential_staff.filter( assigned_ticketprojects__organization=barilla ).distinct() [ <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]customers
barilla_ticket_customers = potential_customers.filter( visible_ticketprojects__organization=barilla ).distinct() [ <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)> ]submitters
barilla_ticket_submitters = contacts.filter( Q(managed_ticketprojects__organization=barilla)| Q(assigned_ticketprojects__organization=barilla)| Q(visible_ticketprojects__organization=barilla), status=1 ).distinct() [ <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]
organization manager staff customer submitter barilla sandro luca francesca francesca vittorino sandro giorgia giorgia vittorino luca sandro vittorino ticket project
barilla sw1
barilla_sw1 = barilla_ticket_projects.get(name='barilla sw1') <TicketProject: barilla sw1 (Barilla)>managers
barilla_sw1_managers = barilla_sw1.managers.filter(status=1) [<Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)>]staff
barilla_sw1_staff = barilla_sw1.staff.filter(status=1) [ <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]customers
barilla_sw1_customers = barilla_sw1.customers.filter(status=1) [<Contact: Sig.a Francesca Francesca (Referente)>]submitters
barilla_sw1_submitters = contacts.filter( Q(managed_ticketprojects=barilla_sw1)| Q(assigned_ticketprojects=barilla_sw1)| Q(visible_ticketprojects=barilla_sw1), status=1 ).distinct() [ <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Luca Luca (Programmatore)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]barilla sw2
barilla_sw2 = barilla_ticket_projects.get(name='barilla sw2') <TicketProject: barilla sw2 (Barilla)>managers
barilla_sw2_managers = barilla_sw2.managers.filter(status=1) [<Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)>]staff
barilla_sw2_staff = barilla_sw2.staff.filter(status=1) [<Contact: Sig. Vittorino Vittorino (Programmatore)>]submitters
barilla_sw2_customers = barilla_sw2.customers.filter(status=1) [<Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>] barilla_sw2_submitters = contacts.filter( Q(managed_ticketprojects=barilla_sw2)| Q(assigned_ticketprojects=barilla_sw2)| Q(visible_ticketprojects=barilla_sw2), status=1 ).distinct() [ <Contact: Sig.a Francesca Francesca (Referente)>, <Contact: Dott. Giorgia Giorgia (Referente)>, <Contact: Dott. Sandro Sandro (Programmatore)>, <Contact: Sig. Vittorino Vittorino (Programmatore)> ]
ticket Project manager staff customer submitter barilla_sw1 sandro luca francesca francesca vittorino sandro luca vittorino sandro vittorino barilla_sw2 sandro vittorino francesca francesca vittorino giorgia giorgia sandro vittorino contacts
vittorino = potential_managers.get(last_name='Vittorino') <Contact: Sig. Vittorino Vittorino (Programmatore)> daniele = potential_staff.get(last_name='Daniele') <Contact: Sig. Daniele Daniele (Sistemista)> giorgia = potential_customers.get(last_name='Giorgia') <Contact: Dott. Giorgia Giorgia (Referente)>is manager
is_manager = vittorino.managed_ticketprojects.all().count() > 0 True is_manager = daniele.managed_ticketprojects.all().count() > 0 False is_manager = giorgia.managed_ticketprojects.all().count() > 0 Falseis staff
is_staff = vittorino.assigned_ticketprojects.all().count() > 0 True is_staff = daniele.assigned_ticketprojects.all().count() > 0 False is_staff = giorgia.assigned_ticketprojects.all().count() > 0 Falseis customer
is_customer = vittorino.visible_ticketprojects.all().count() > 0 False is_customer = daniele.visible_ticketprojects.all().count() > 0 False is_customer = giorgia.visible_ticketprojects.all().count() > 0 Trueis submitter
is_submitter = active_ticket_projects.filter( Q(managers=vittorino)| Q(staff=vittorino)| Q(customers=vittorino) ).count() > 0 True is_submitter = active_ticket_projects.filter( Q(managers=daniele)| Q(staff=daniele)| Q(customers=daniele) ).count() > 0 False is_submitter = active_ticket_projects.filter( Q(managers=giorgia)| Q(staff=giorgia)| Q(customers=giorgia) ).count() > 0 True
contact M A V S vittorino T T F T daniele F F F F giorgia F F T T ticket organizations
vittorino
vittorino_managed_organizations = customer_organizations.filter( projects__ticketproject__managers=vittorino ).distinct() [<Organization: Barilla>, <Organization: De Cecco>] vittorino_assigned_organizations = customer_organizations.filter( projects__ticketproject__staff=vittorino ).distinct() [<Organization: Barilla>, <Organization: De Cecco>] vittorino_visible_organizations = customer_organizations.filter( projects__ticketproject__customers=vittorino ).distinct() [] vittorino_ticket_organizations = customer_organizations.filter( Q(projects__ticketproject__managers=vittorino)| Q(projects__ticketproject__staff=vittorino)| Q(projects__ticketproject__customers=vittorino) ).distinct() [<Organization: Barilla>, <Organization: De Cecco>, <Organization: Voiello>]luca
luca_managed_organizations = customer_organizations.filter( projects__ticketproject__managers=luca ).distinct() [] luca_assigned_organizations = customer_organizations.filter( projects__ticketproject__staff=luca ).distinct() [<Organization: Barilla>, <Organization: Voiello>] luca_visible_organizations = customer_organizations.filter( projects__ticketproject__customers=luca ).distinct() [] luca_ticket_organizations = customer_organizations.filter( Q(projects__ticketproject__managers=luca)| Q(projects__ticketproject__staff=luca)| Q(projects__ticketproject__customers=luca) ).distinct() []daniele
daniele_managed_organizations = customer_organizations.filter( projects__ticketproject__managers=daniele ).distinct() [] daniele_assigned_organizations = customer_organizations.filter( projects__ticketproject__staff=daniele ).distinct() [] daniele_visible_organizations = customer_organizations.filter( projects__ticketproject__customers=daniele ).distinct() [] daniele_ticket_organizations = customer_organizations.filter( Q(projects__ticketproject__managers=daniele)| Q(projects__ticketproject__staff=daniele)| Q(projects__ticketproject__customers=daniele) ).distinct() []giorgia
giorgia_managed_organizations = customer_organizations.filter( projects__ticketproject__managers=giorgia ).distinct() [] giorgia_assigned_organizations = customer_organizations.filter( projects__ticketproject__staff=giorgia ).distinct() [] giorgia_visible_organizations = customer_organizations.filter( projects__ticketproject__customers=giorgia ).distinct() [<Organization: Barilla>] giorgia_ticket_organizations = customer_organizations.filter( Q(projects__ticketproject__managers=giorgia)| Q(projects__ticketproject__staff=giorgia)| Q(projects__ticketproject__customers=giorgia) ).distinct() [<Organization: Barilla>]ticket projects
vittorino
vittorino_managed_ticket_projects = active_ticket_projects.filter( managers=vittorino ).distinct() [ <TicketProject: barilla sw1 (Barilla)>, <TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)>, <TicketProject: de cecco sw (De Cecco)> ] vittorino_assigned_ticket_projects = active_ticket_projects.filter( staff=vittorino ).distinct() [ <TicketProject: barilla sw1 (Barilla)>, <TicketProject: barilla sw2 (Barilla)>, <TicketProject: voiello sw (Voiello)> ] vittorino_visible_ticket_projects = active_ticket_projects.filter( customers=vittorino ).distinct() [] vittorino_ticket_projects = active_ticket_projects.filter( Q(managers=vittorino)| Q(staff=vittorino)| Q(customers=vittorino) ).distinct() [ <TicketProject: barilla sw1 (Barilla)>, <TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)>, <TicketProject: de cecco sw (De Cecco)>, <TicketProject: voiello sw (Voiello)> ]luca
luca_managed_ticket_projects = active_ticket_projects.filter( managers=luca ).distinct() [] luca_assigned_ticket_projects = active_ticket_projects.filter( staff=luca ).distinct() [<TicketProject: barilla sw1 (Barilla)>, <TicketProject: voiello sw (Voiello)>] luca_visible_ticket_projects = active_ticket_projects.filter( customers=luca ).distinct() [] luca_ticket_projects = active_ticket_projects.filter( Q(managers=luca)| Q(staff=luca)| Q(customers=luca) ).distinct() [<TicketProject: barilla sw1 (Barilla)>, <TicketProject: voiello sw (Voiello)>]daniele
daniele_managed_ticket_projects = active_ticket_projects.filter( managers=daniele ).distinct() [] daniele_assigned_ticket_projects = active_ticket_projects.filter( staff=daniele ).distinct() [] daniele_visible_ticket_projects = active_ticket_projects.filter( customers=daniele ).distinct() [] daniele_ticket_projects = active_ticket_projects.filter( Q(managers=daniele)| Q(staff=daniele)| Q(customers=daniele) ).distinct() []giorgia
giorgia_managed_ticket_projects = active_ticket_projects.filter( managers=giorgia ).distinct() [] giorgia_assigned_ticket_projects = active_ticket_projects.filter( staff=giorgia ).distinct() giorgia_visible_ticket_projects = active_ticket_projects.filter( customers=giorgia ).distinct() [<TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)>] giorgia_ticket_projects = active_ticket_projects.filter( Q(managers=giorgia)| Q(staff=giorgia)| Q(customers=giorgia) ).distinct() [<TicketProject: barilla sw2 (Barilla)>, <TicketProject: barilla sw3 (Barilla)>]