# (c) cavaliba.com

# demo - project portfolio management - pmo.yaml


# ------------------------------------
# Permissions, group, role
# ------------------------------------

- classname: _permission
  keyname: p_project_view
  displayname: Projects (read-only)
  description: Projects access in read-only mode

- classname: _permission
  keyname: p_project_edit
  displayname: Projects (read-write)
  description: Projects access in read-write mode

- classname: _group
  keyname: g_project
  displayname: Groupe Projets
  description: All projects contributors
  #subgroups:
  #    - other_group
  users: 
      - j.smith

- classname: _role
  keyname: role_project
  displayname: Project Role
  permissions:
     - p_project_view
     - p_project_edit
  subgroups:
      - g_project


# -------------------------------------------------
# Enumerate
# -------------------------------------------------

- classname: _enumerate
  keyname: project_size
  displayname: Project Size
  description: XXL / XL / M / S / XS / other
  content: |
    - value: "XXL"
    - value: "XL"
    - value: "M"
    - value: "S"
    - value: "XS"
    - value: "other"

- classname: _enumerate
  keyname: project_state
  displayname: "Project State"
  description: "Project states"
  content: |
    - value: "prepare"
      long: "init / in preparation"
    - value: "active"
      long: "currently active"
    - value: "suspended"
      long: "temporarily suspended"
    - value: "canceled"
      long: "definitely abandonned"
    - value: "done"
      long: "done"
    - value: "other"
      long: "other, n/a"



# Study/Hardware/Software/Process/Other
- classname: _enumerate
  keyname: project_type
  displayname: "Project types"
  description: "Project types"
  content: |
    - value: "Production"
    - value: "R&D"
    - value: "Building"
    - value: "Marketting"
    - value: "IT"
    - value: "Other"


# very good / good / average / bad / crisis / other
- classname: _enumerate
  keyname: project_health
  displayname: "Project Health"
  description: "Project overall health"
  content: |
    - value: "Very good"
      widget: "green_circle"
    - value: "Good"
      widget: "yellow_circle"
    - value: "Average"
      widget: "orange_circle"
    - value: "Bad"
      widget: "red_circle"
    - value: "Crisis"
      widget: "black_circle"
    - value: "other"
      widget: "white_circle"


- classname: _enumerate
  keyname: project_trend
  displayname: Project Trend
  description: Trend
  content: |
    - value: "++"
      long: string UP
      widget: html <i class="fa fa-arrow-up"></i>&nbsp;
    - value: "=="
      widget: html <i class="fa fa-arrow-right"></i>&nbsp;
    - value: "--"
      widget: html <i class="fa fa-arrow-down"></i>&nbsp;


- classname: _enumerate
  keyname: enumerate_country
  displayname: Country
  description: Country and infos
  content: |
    - value: ES
      long: string Spain
    - value: FR
      long: string France
    - value: IT
      long: string Italy
    - value: UK
      long: string United Kingdom
    - value: SW
      long: string Sweden
    - value: US
      long: string United States
    - value: DE
      long: string Germany
    - value: BE
      long: string Belgium
    - value: JP
      long: string Japan
    - value: AU
      long: string Australia

# -------------------------------------------------
# PROGRAM
# -------------------------------------------------

- classname: _schema
  keyname: program
  displayname: Programs and Project Portfolios
  page: PMO - Projects  
  icon: fa-diamond
  handle_method: md5
  p_admin: p_project_edit
  p_read: p_project_view
  p_create: p_project_edit
  p_update: p_project_edit
  p_delete: p_project_edit
  p_import: p_project_edit
  p_export: p_project_edit

  label:      
      displayname: Label
      dataformat: string
      order: 110
      page: Program
      cardinal_min: 0
      cardinal_max: 1

  pg_owner:
      displayname: Program Owner
      dataformat: user
      description: Program owner
      order: 120
      page: Program
      cardinal_min: 0
      cardinal_max: 1

  country:
      displayname: Country
      dataformat: enumerate
      dataformat_ext: enumerate_country
      order: 120
      page: Program
      cardinal_min: 0
      cardinal_max: 1


# -------------------------------------------------
# PROJECT
# -------------------------------------------------

- classname: _schema
  keyname: project
  displayname: Projects
  page: PMO - Projects
  icon: fa-cube
  handle_method: md5
  p_admin: p_project_edit
  p_read: p_project_view
  p_create: p_project_edit
  p_update: p_project_edit
  p_delete: p_project_edit
  p_import: p_project_edit
  p_export: p_project_edit

# 100 - ID

  description:
        displayname: Short Description
        dataformat: string
        description: One liner pitch
        order: 100
        page: Project Identity

  size:      
        displayname: project size
        dataformat: enumerate
        dataformat_ext: project_size
        description: XXL/XL/M/S/XS/other
        order: 110
        page: Project Identity
        cardinal_min: 0
        cardinal_max: 1

  state:      
        displayname: project state
        dataformat: enumerate
        dataformat_ext: project_state
        description: prepare/active/suspended/canceled/done/other
        order: 120
        page: Project Identity
        cardinal_min: 0
        cardinal_max: 1

  type:      
        displayname: project type
        dataformat: enumerate
        dataformat_ext: project_type
        description: Production/R&D/Building/Marketting/IT/Other
        order: 130
        page: Project Identity
        cardinal_min: 0
        cardinal_max: 1

  special:
        displayname: Special Project
        dataformat: boolean
        description: Special Project
        order: 140
        page: Project Identity

  external_id:
        displayname: External ID
        dataformat: string
        description: Project ID from Financial System
        order: 150
        page: Project Identity

  program:
        displayname: Program
        dataformat: schema
        dataformat_ext: program country pg_owner
        description: Program
        order: 160
        page: Project Identity


# 200 - Scope / Perimeter / Deliverable


  scope:
        displayname: Project objectives
        dataformat: text
        dataformat_ext: markdown
        description: Lengthy project objectives and deliverables
        order: 210
        page: Scope
        cardinal_min: 0
        cardinal_max: 1

  target_site:      
        displayname: Target Site 
        dataformat: schema
        dataformat_ext: site
        description: Geographical Site 
        order: 200
        page: Scope
        cardinal_min: 0
        cardinal_max: 0


# 300 - organization
 
  owner:
      displayname: PM - Project Owner
      dataformat: user
      description: Project owner
      order: 310
      page: Organization
      cardinal_min: 0
      cardinal_max: 1

  pm:      
      displayname: PM - Project manager
      dataformat: user
      description: Project manager
      order: 300
      page: Organization
      cardinal_min: 0
      cardinal_max: 1

  members:
      displayname: PM - Project Members
      dataformat: user
      description: Project Members (people)
      order: 320
      page: Organization
      cardinal_min: 0
      cardinal_max: 0

  groups:
        displayname: Organization Groups
        dataformat: group
        description: User groups involved
        order: 330
        page: Organization
        cardinal_max: 0
        cardinal_max: 0

# 400 - Calendar

  project_start:
        displayname: Start date
        page: Calendar
        order: 400
        dataformat: date

  project_end:
        displayname: End date (due)
        page: Calendar
        order: 410
        dataformat: date


# 500 - ressources

  budget_allocated:
      displayname: "Budget allocated (K€)"
      page: Ressources
      order: 500
      dataformat: float
      dataformat_ext: gte_0 lt_100
      description: "constraint: decimal number in [0, 100["

  budget_spent:
      displayname: Budget spent (K€)
      page: Ressources
      order: 510
      dataformat: float   
      dataformat_ext: ge_0 
   
  workforce_allocated:
        displayname: Workforce allocated (man.days)
        page: Ressources
        order: 520
        dataformat: int
        dataformat_ext: gte_0 lte_500
        description: "constraint: integer value in [0, 500]"
  
  workforce_spent:
        displayname: Workforce spent (man.days spent)
        page: Ressources
        order: 530
        dataformat: int
        dataformat_ext: ge_0


# 600 - status / progress

  status_global:
        displayname: Status
        dataformat: enumerate
        dataformat_ext: project_health
        description: very good / good / average / bad / worse / other
        order: 600
        page: Project Status and Health
        cardinal_min: 0
        cardinal_max: 1

  status_trend:
        displayname: Trend
        dataformat: enumerate
        dataformat_ext: project_trend
        description: UP / EGAL / DOWN
        order: 600
        page: Project Status and Health
        cardinal_min: 0
        cardinal_max: 1

  status_budget:
        displayname: Budget
        dataformat: enumerate
        dataformat_ext: project_health
        description: very good / good / average / bad / worse / other
        order: 610
        page: Project Status and Health
        cardinal_min: 0
        cardinal_max: 1

  status_workforce:
        displayname: Workforce
        dataformat: enumerate
        dataformat_ext: project_health
        description: very good / good / average / bad / worse / other
        order: 620
        page: Project Status and Health
        cardinal_min: 0
        cardinal_max: 1

  status_deliverable:
        displayname: Deliverable
        dataformat: enumerate
        dataformat_ext: project_health
        description: very good / good / average / bad / worse / other
        order: 630
        page: Project Status and Health
        cardinal_min: 0
        cardinal_max: 1

  pm_comment:
        displayname: PM comment
        dataformat: text
        description: Project Manager short report
        order: 640
        page: Project Status and Health
        cardinal_min: 0
        cardinal_max: 1

  pm_last_update:
        displayname: Last update date (by Project Manager)
        page: Project Status and Health
        order: 650
        dataformat: date



# -------------------------------------------------
# dataview
# -------------------------------------------------

- classname: _dataview
  keyname: project_identity
  displayname: Project Identity
  is_enabled: true
  description: Project overview
  target_class: project
  content: |
    columns:
        - keyname
        - displayname
        - program
        - PG owner:
            from: program__pg_owner
        - country:
            from: program__country
        - Sponsor:
            from: owner
        - pm
        - size
        - state
        - type
        - special
        - external_id

- classname: _dataview
  keyname: project_program
  displayname: Project_Program
  description: Project Program
  target_class: project
  content: |
    columns:
        - keyname
        - displayname
        - Program:
            from: program
        - Program owner:
            from: program__pg_owner
        - Program Country:
            from: program__country
        - Program Country (long):
            from: program__country__long
        - Project Sponsor:
            from: owner
        - Project Manager:
            from: pm


- classname: _dataview
  keyname: project_organization
  displayname: Project Organization
  is_enabled: true
  description: Project Management and Actors
  target_class: project
  content: |
    columns:
        - keyname
        - owner
        - Project Manager:
           from: pm
        - members
        - groups

- classname: _dataview
  keyname: project_ressource
  displayname: Project Ressources
  is_enabled: true
  description: Project Budget, People, Date
  target_class: project
  content: |
    columns:
        - keyname
        - project_start
        - project_end
        - "K€ allocated":
              from: budget_allocated
        - "K€ spent":
              from: budget_spent
        - workforce_allocated
        - workforce_spent

- classname: _dataview
  keyname: project_status
  displayname: Project Status
  is_enabled: true
  description: Project Health and Progress
  target_class: project
  content: |
    columns:
        - keyname
        - Global:
             from: status_global
        - Trend:
             from: status_trend
        - Budget:
             from: status_budget
        - Workforce:
             from: status_workforce
        - Deliverable:
             from:  status_deliverable
        - Project Manager:
           from: pm
        - Comment:
            from: pm_comment
        - Update:
            from: pm_last_update

## Programs


- classname: _dataview
  keyname: program_default
  displayname: Program (default)
  is_enabled: true
  description: Default Dataview for Programs
  target_class: program
  content: |
    columns:
        - keyname
        - displayname
        - Label:
             from: label
        - Country:
            from: country
        - Country name:
            from: country__long


# -------------------------------------------------
# pipeline
# -------------------------------------------------

#  docker exec -it cavaliba_app python manage.py cavaliba_load /files/demo/pmo/pmo.csv --pipeline project_from_csv

# demo:  pmo.csv
# keyname|displayname|size|state|type|budget
# project 01|Project number 1|XL|prepare|R&D|56.3
# project 02|Project number 2|L|active|R&D|22.2
# project 03|Project number 3|XXL|active|Production|300
# project 04|Project number 4|M|active|Building|44
# project 05|Project number 5|XS|canceled|R&D|5.1
# project 06|Project number 6|XS|prepare|Marketing|66.6
# project 07|Project number 7 is strange||||
# project 08|||||
# project 09|Project too big|XXXXL|||

- classname: _pipeline
  keyname: project_from_csv
  displayname: Demo - Load CSV with projects
  is_enabled: true
  description: Demo - Pipeline to import projects from a CSV file
  content: |
      csv_delimiter: '|'
      classname: project
      keyfield: keyname
      tasks: 
          # TASKNAME: ['CONDITION', 'taskopt', 'taskopt', '...']
        - field_rename: ['', 'budget','budget_allocated']
        - field_lower: ['', owner, pm]
        - field_delete : ['', useless_field_if_here]
        - field_regexp_sub: ["", "size", "XXXXL","XXL"]



# -------------------------------------------------
# Home Widget / Sidebar
# -------------------------------------------------

- classname: _home
  keyname: data_project
  displayname: PMO - Projects
  description: PMO - Projects list
  icon: fa-cube
  url: /data/private/c/project/list/
  dashboard_section: PMO Projects
  sidebar_section: PMO Projects
  order: 150
  permission: p_project_view

- classname: _home
  keyname: data_program
  displayname: PMO - Program
  description: PMO - Program List
  icon: fa-cube
  url: /data/private/c/program/list/
  dashboard_section: PMO Projects
  sidebar_section: PMO Projects
  order: 151
  permission: p_project_view

