SahanaCamp NYC Day 3: Eden Technical Workshop
Upcoming SlideShare
Loading in...5
×
 

SahanaCamp NYC Day 3: Eden Technical Workshop

on

  • 1,543 views

SahanaCamp NYC Day 3 - Eden Technical Workshop

SahanaCamp NYC Day 3 - Eden Technical Workshop

Statistics

Views

Total Views
1,543
Views on SlideShare
1,014
Embed Views
529

Actions

Likes
0
Downloads
11
Comments
0

5 Embeds 529

http://sahanafoundation.org 515
http://sahana-wordpress.osuosl.org 10
http://us-w1.rockmelt.com 2
http://translate.googleusercontent.com 1
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

SahanaCamp NYC Day 3: Eden Technical Workshop SahanaCamp NYC Day 3: Eden Technical Workshop Presentation Transcript

  • Sahana EdenTechnical Workshop Fran Boon fran@sahanafoundation.org SahanaCamp NYC 1
  • AgendaThursday 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
  • AgendaFriday 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 MattersUnlike other languages which use parentheses todelimit code blocks {...}, Python instead uses WhiteSpace SahanaCamp NYC 5
  • Debug Modemodels/000_config.pydeployment_settings.base.debug = True  Reloads modules/eden every request  CSS & JavaScript unminified SahanaCamp NYC 6
  • Training ModuleResource: Course Name Date / Time Location: Venue Facilitator Welcome Pack SahanaCamp NYC 7
  • Define the Basic Data Modelmodels/training.pytablename = "training_course"db.define_table(tablename, Field("name"), Field("start"), Field("facilitator"), ) Table Name: module_resource Database migrated automatically SahanaCamp NYC 8
  • Add a Controllercontrollers/training.pydef 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 Formatshttp://127.0.0.1:8000/eden/training/course .xlshttp://127.0.0.1:8000/eden/training/course .xmlhttp://127.0.0.1:8000/eden/training/course .json SahanaCamp NYC 11
  • Pivot Table Reportshttp://127.0.0.1:8000/eden/training/course /report SahanaCamp NYC 12
  • Field Typesmodels/training.py Field("start", "datetime"), Field("welcome_pack", "upload"), SahanaCamp NYC 13
  • Field Labelsmodels/training.py Field("start", "datetime", label=T("Start Date")), SahanaCamp NYC 14
  • Links to other Resourcesmodels/training.pytablename = "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 Resourcesmodels/training.pytablename = "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 Resourcesmodels/training.pys3db.super_link("site_id", "org_site", label = "Venue", readable = True, writable = True, represent = s3db.org_site_represent, ), SahanaCamp NYC 17
  • Menus: Top levelmodels/000_config.pydeployment_settings.modules = OrderedDict([ ("training", Storage( name_nice = "Training", module_type = 1, )), SahanaCamp NYC 18
  • Menus: 2nd levelmodules/eden/menus.pyclass 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 Pagehttp://127.0.0.1:8000/eden/training/indexcontrollers/training.pydef index(): return dict() Pass control to a view template SahanaCamp NYC 20
  • Module Index Pageviews/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 Pageviews/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
  • ResourcesDominic KoenigSahanaCamp NYC 23
  • ComponentsParticipants of a Course SahanaCamp NYC 24
  • ComponentsParticipants of a Course SahanaCamp NYC 25
  • Componentsmodels/training.pytablename = "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 Headercontrollers/training.pydef 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 Headercontrollers/training.pydef 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/functioneg: 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/resourceeg: 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
  • ViewsGeneric View:web2py/applications/eden/views/_list_create.htmlIf 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 Labelmodules/eden/org.pytablename = "org_organisation"... Field("donation_phone", label = T("Donation Phone Number"), SahanaCamp NYC 34
  • Hide a Fieldmodules/eden/org.pytablename = "org_office"... Field("type", "integer readable=False, writable=False, label=T("Type")), SahanaCamp NYC 35
  • Add a New Fieldmodules/eden/org.pytablename = "org_organisation"... Field("facebook", label=T("Facebook Page")), SahanaCamp NYC 36
  • Edit the Menusmodules/eden/menus.pydef 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 Boonfran@sahanafoundation.org SahanaCamp NYC 38
  • AgendaInstalling GitCreating your own BranchSharing your Code with the Community SahanaCamp NYC 39
  • Installing GitGitHub.com has excellent instructionsCreate SSH public/private keysssh-keygen -t rsa -C “my_email@email.com” SahanaCamp NYC 40
  • Creating your Branchhttps://github.com/flavour/edenGet local copy: git clone git@github.com:myname/eden.gitStay up date: git pull upstream master SahanaCamp NYC 41
  • Sharing your CodeCommit code locally: git commit -aPush to GitHub: git pushSubmit Pull Request to get code merged into Trunk SahanaCamp NYC 42
  • SahanaCamp NYC 43