SlideShare a Scribd company logo
Sahana Eden
Technical Workshop
         Fran Boon
   fran@sahanafoundation.org



         SahanaCamp NYC        1
Agenda
Thursday
   10:30   Installing a Developer Environment
   11:30   Building your own Applications
   12:00   Lunch
   13:00   Building your own Applications
   13:30   Resources
   14:00   Building your own Applications
   14:30   Modifying existing Applications
   15:45   Git and GitHub
   16:25   Plan Breakout Sessions
   17:00   Adjourn
                     SahanaCamp NYC               2
Agenda
Friday
   09:00   Breakout Sessions
   10:45   Code Sprint: Your Projects
   12:00   Working Lunch
   13:00   Next Steps
   13:30   Community Resources
   14:00   Adjourn




                     SahanaCamp NYC           3
Building your own
  Applications
        Fran Boon
  fran@sahanafoundation.org



        SahanaCamp NYC        4
Whitespace Matters
Unlike other languages which use parentheses to
delimit code blocks {...}, Python instead uses White
Space




                     SahanaCamp NYC                    5
Debug Mode
models/000_config.py

deployment_settings.base.debug = True


     Reloads modules/eden every request
     CSS & JavaScript unminified




                               SahanaCamp NYC            6
Training Module
Resource: 'Course'
   Name
   Date / Time
   Location: Venue
   Facilitator
   Welcome Pack




                      SahanaCamp NYC           7
Define the Basic Data Model
models/training.py

tablename = "training_course"
db.define_table(tablename,
                Field("name"),
                Field("start"),
                Field("facilitator"),
                )

   Table Name: module_resource
   Database 'migrated' automatically




                       SahanaCamp NYC    8
Add a Controller
controllers/training.py

def course():
    return s3_rest_controller()

   Functions map URLs to code
    & resources




                      SahanaCamp NYC                9
Try it out!
http://127.0.0.1:8000/eden/training/course

   List
   Create
   Read
   Update
   Delete




                   SahanaCamp NYC             10
Other Formats
http://127.0.0.1:8000/eden/training/course .xls


http://127.0.0.1:8000/eden/training/course .xml


http://127.0.0.1:8000/eden/training/course .json




                 SahanaCamp NYC                    11
Pivot Table Reports
http://127.0.0.1:8000/eden/training/course /report




                   SahanaCamp NYC                12
Field Types
models/training.py

  Field("start", "datetime"),
  Field("welcome_pack", "upload"),




                   SahanaCamp NYC              13
Field Labels
models/training.py

  Field("start", "datetime",
        label=T("Start Date")),




                   SahanaCamp NYC              14
Links to other Resources
models/training.py

tablename = "training_course"
db.define_table(tablename,
                 Field("name"),
                 Field("start", "datetime",
                       label = "Start Date"),
                 s3db.pr_person_id(label="Facilitator"),
                 Field("welcome_pack", "upload"),
               )




                      SahanaCamp NYC                       15
Links to other Resources
models/training.py

tablename = "training_course"
db.define_table(tablename,
           Field("name"),
           Field("start", "datetime",
                 label = "Start Date"),
           s3db.pr_person_id(label="Facilitator"),
           s3db.super_link("site_id","org_site"),
           Field("welcome_pack", "upload"),
           )




                     SahanaCamp NYC                  16
Links to other Resources
models/training.py

s3db.super_link("site_id", "org_site",
                label = "Venue",
                readable = True,
                writable = True,
                represent = s3db.org_site_represent,
                ),




                     SahanaCamp NYC                    17
Menus: Top level
models/000_config.py

deployment_settings.modules = OrderedDict([
    ("training", Storage(
        name_nice = "Training",
        module_type = 1,
    )),




                     SahanaCamp NYC           18
Menus: 2nd level
modules/eden/menus.py

class S3OptionsMenu:

    def training(self):
        return M(c="training")(
                    M("Courses", f="course")(
                        M("New", m="create"),
                        M("List All"),
                        M("Report", m="report"),
                      )
                )


                       SahanaCamp NYC              19
Module Index Page
http://127.0.0.1:8000/eden/training/index

controllers/training.py

def index():
    return dict()


   Pass control to a view template




                       SahanaCamp NYC        20
Module Index Page
views/training/index.html

{{extend "layout.html"}}
<H1>Welcome to the Training Module</H1>
<UL>
<LI>Browse the Course List
</UL>

   HTML with Python inside {{..}}
   Extend layout.html for basic look and feel




                        SahanaCamp NYC           21
Module Index Page
views/training/index.html

{{extend "layout.html"}}
<H2>Welcome to the Training Module</H2>
<UL>
<LI>Browse the {{=A("Course List",
_href=URL(c="training", f="course"))}}
</UL>




                     SahanaCamp NYC       22
Resources
Dominic Koenig




SahanaCamp NYC   23
Components
Participants of a Course




                    SahanaCamp NYC            24
Components
Participants of a Course




                    SahanaCamp NYC            25
Components
models/training.py

tablename = "training_participant"
db.define_table(tablename,
                s3db.pr_person_id(),
                Field("course_id",
                      db.training_course
                      )
                )
s3db.add_component("training_participant",
                   training_course="course_id")




                     SahanaCamp NYC               26
Resource Header
controllers/training.py

def course_rheader(r):
    if r.record:
        tabs = [("Basic Details", None),
                ("Participants", "participant")
               ]
         rheader_tabs = s3_rheader_tabs(r, tabs)
        rheader = DIV(TABLE(
                          TR(TH("Name: "),
                             r.record.name),
                            ), rheader_tabs)
        return rheader

                     SahanaCamp NYC                27
Resource Header
controllers/training.py

def course():
    return s3_rest_controller(rheader=course_rheader)


http://127.0.0.1:8000/eden/training/course/1/participant




                     SahanaCamp NYC                     28
Modifying Existing
  Applications
        Fran Boon
  fran@sahanafoundation.org



        SahanaCamp NYC        29
Which file do I edit?
Each module will have:
    Model: modules/eden/modulename.py
    View: views/modulename/index.html
     There may be additional view files for custom pages
    Controller: controllers/modulename.py




                           SahanaCamp NYC                  30
Web2Py URL Mapping
  http://host/application/controller/function



eg: http://127.0.0.1:8000/eden/default/index


     Model: not    applicable here

     View: web2py/applications/eden/views/default/index.html
     Controller: web2py/applications/eden/controllers/default.py
         Function: def   index():




                              SahanaCamp NYC                        31
Sahana Eden URL Mapping
          http://host/eden/module/resource

eg: http://127.0.0.1:8000/eden/org/site

     Model: web2py/applications/eden/modules/eden/org.py
         tablename = "org_site"

     View: not    applicable here

     Controller: web2py/applications/eden/controllers/org.py
         Function: def   site():
                          return s3_rest_controller()


                               SahanaCamp NYC                   32
Views
Generic View:
web2py/applications/eden/views/_list_create.html




If you want to create a custom view then:


Custom View:
web2py/applications/eden/views/org/site_list_create.html




                          SahanaCamp NYC                       33
Edit a Field Label
modules/eden/org.py

tablename = "org_organisation"
...
    Field("donation_phone",
          label = T("Donation Phone Number"),




                     SahanaCamp NYC             34
Hide a Field
modules/eden/org.py

tablename = "org_office"
...
    Field("type",
          "integer
          readable=False,
          writable=False,
          label=T("Type")),




                     SahanaCamp NYC              35
Add a New Field
modules/eden/org.py

tablename = "org_organisation"
...
    Field("facebook", label=T("Facebook Page")),




                     SahanaCamp NYC                36
Edit the Menus
modules/eden/menus.py
def org(self):
 """ ORG / Organization Registry """
 return M(c="org")(
           M("Organizations", f="organisation")(
               M("New", m="create"),
               M("List All"),
               M("Search", m="search"),
               M("Import", m="import")
           ),
           M("Venues", f="office")(
           M("New", m="create"),
               M("List All"),
               #M("Search", m="search"),
               M("Import", m="import")
           ),
       )
                       SahanaCamp NYC              37
Git and GitHub
      Fran Boon
fran@sahanafoundation.org




      SahanaCamp NYC        38
Agenda
Installing Git
Creating your own Branch
Sharing your Code with the Community




                 SahanaCamp NYC             39
Installing Git
GitHub.com has excellent instructions




Create SSH public/private keys
ssh-keygen -t rsa -C “my_email@email.com”




                   SahanaCamp NYC               40
Creating your Branch
https://github.com/flavour/eden


Get local copy: git   clone git@github.com:myname/eden.git

Stay up date: git   pull upstream master




                      SahanaCamp NYC                    41
Sharing your Code
Commit code locally: git     commit -a

Push to GitHub: git   push

Submit Pull Request to get code merged into Trunk




                  SahanaCamp NYC                42
SahanaCamp NYC   43

More Related Content

PPTX
Sahana eden
PDF
SahanaCamp NYC Day 2 PM: Partnerships with the Sahana Software Foundation
PDF
SahanaCamp NYC Day 1 AM: Sahana Eden Case Studies
PPTX
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
PDF
Sahana Workshop Pokhara Nepal
PPT
Sahana Overview
PDF
Sahana Eden Brochure
PDF
Tech 1 - Deploying Sahana Eden
Sahana eden
SahanaCamp NYC Day 2 PM: Partnerships with the Sahana Software Foundation
SahanaCamp NYC Day 1 AM: Sahana Eden Case Studies
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
Sahana Workshop Pokhara Nepal
Sahana Overview
Sahana Eden Brochure
Tech 1 - Deploying Sahana Eden

Similar to SahanaCamp NYC Day 3: Eden Technical Workshop (20)

PPT
Major Java 8 features
PDF
Camunda BPM 7.2: Tasklist and Javascript Forms SDK (English)
PDF
SCALA - Functional domain
KEY
Django quickstart
PPTX
New features in jdk8 iti
PDF
Introduction to Django
PDF
Odoo - Backend modules in v8
PDF
lecture5
PDF
lecture5
PDF
A Basic Django Introduction
PDF
Nhibernate Part 2
PDF
Serverless ML Workshop with Hopsworks at PyData Seattle
PPTX
1403 app dev series - session 5 - analytics
PPTX
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
PDF
大規模サイトにおけるユーザーレベルのキャッシュ活用によるパフォーマンスチューニング
PDF
Benchy, python framework for performance benchmarking of Python Scripts
PDF
Aplicacoes dinamicas Rails com Backbone
PPTX
20140821 delapsley-cloudopen-public
PDF
Real world scala
PDF
Multilingualism makes better programmers
Major Java 8 features
Camunda BPM 7.2: Tasklist and Javascript Forms SDK (English)
SCALA - Functional domain
Django quickstart
New features in jdk8 iti
Introduction to Django
Odoo - Backend modules in v8
lecture5
lecture5
A Basic Django Introduction
Nhibernate Part 2
Serverless ML Workshop with Hopsworks at PyData Seattle
1403 app dev series - session 5 - analytics
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
大規模サイトにおけるユーザーレベルのキャッシュ活用によるパフォーマンスチューニング
Benchy, python framework for performance benchmarking of Python Scripts
Aplicacoes dinamicas Rails com Backbone
20140821 delapsley-cloudopen-public
Real world scala
Multilingualism makes better programmers
Ad

More from Sahana Software Foundation (20)

PDF
Sahana Software Foundation Overview Brief - Long
PDF
Prutsalis Urgency Of Reading International Symposium - HFOSS Disaster Managem...
PDF
Sahana Eden NYC Python Meetup - July 9, 2013
PDF
Sahana CiMAG May 2013
PDF
Sahana Eden NEREIDS Cyprus
PDF
Sahana at #NYTechResponds
PDF
Sahana EUROSHA - Open World Forum 2012
PDF
Prutsalis WCDM Narrative
PDF
Prutsalis WCDM Address
PDF
SSF 2011 Annual Report
PDF
SSF 2012 Annual Meeting Master
PDF
SahanaCamp NYC Day 2 PM: Managing A Deployment
PDF
SahanaCamp NYC Day 2 PM: Deploying Sahana Eden
PDF
SahanaCamp NYC Day 2 AM: Introduction to SEMS
PDF
SahanaCamp NYC Day 1 PM: Simulation
PDF
SahanaCamp NYC Day 1 AM: Sahana Software Solutions
PDF
Introduction to Sahana Eden - EMAG - May 2012
PDF
Sahana at St. Johns University
PDF
Disasters Roundtable Abstract: Opportunities for Information and Technologica...
PDF
Disasters Roundtable: Opportunities for Information and Technological Recovery
Sahana Software Foundation Overview Brief - Long
Prutsalis Urgency Of Reading International Symposium - HFOSS Disaster Managem...
Sahana Eden NYC Python Meetup - July 9, 2013
Sahana CiMAG May 2013
Sahana Eden NEREIDS Cyprus
Sahana at #NYTechResponds
Sahana EUROSHA - Open World Forum 2012
Prutsalis WCDM Narrative
Prutsalis WCDM Address
SSF 2011 Annual Report
SSF 2012 Annual Meeting Master
SahanaCamp NYC Day 2 PM: Managing A Deployment
SahanaCamp NYC Day 2 PM: Deploying Sahana Eden
SahanaCamp NYC Day 2 AM: Introduction to SEMS
SahanaCamp NYC Day 1 PM: Simulation
SahanaCamp NYC Day 1 AM: Sahana Software Solutions
Introduction to Sahana Eden - EMAG - May 2012
Sahana at St. Johns University
Disasters Roundtable Abstract: Opportunities for Information and Technologica...
Disasters Roundtable: Opportunities for Information and Technological Recovery
Ad

Recently uploaded (20)

PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Chapter 5: Probability Theory and Statistics
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
August Patch Tuesday
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Approach and Philosophy of On baking technology
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Tartificialntelligence_presentation.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
TLE Review Electricity (Electricity).pptx
Hindi spoken digit analysis for native and non-native speakers
Chapter 5: Probability Theory and Statistics
NewMind AI Weekly Chronicles - August'25-Week II
August Patch Tuesday
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Approach and Philosophy of On baking technology
Univ-Connecticut-ChatGPT-Presentaion.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Assigned Numbers - 2025 - Bluetooth® Document
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
OMC Textile Division Presentation 2021.pptx
A comparative analysis of optical character recognition models for extracting...
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Tartificialntelligence_presentation.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
DP Operators-handbook-extract for the Mautical Institute
TLE Review Electricity (Electricity).pptx

SahanaCamp NYC Day 3: Eden Technical Workshop