Navigation Menu

Skip to content

platipusica/Cohorts

Repository files navigation

Cohorts Training Jam.py Application

Welcome!

This is the Application hosted on Heroku for managing staff training, developed with Jam.py Application Builder:

https://cohortstraining.herokuapp.com/

About the App by original Author:

"Administration of this is done by my team for employees. It's not intended for employees to use themselves. Staff are assigned to cohorts by the team as part of the booking process and this is done from the staff view/edit form where the staff_cohorts is a details. I have buttons that, when a staff member is selected, it opens straight to the add to cohort screen with some hacky jquery automation.

The code that wasn't included from the cohorts view is that we use the multi-select and can assign specific training modules (which is another details view on staff) to some/all of the staff in a specific cohort once they have completed them as part of their classes. Also the ability to generate a list of email addresses for all of the the staff in a cohort to contact them. The intention isn't to change cohort membership from this side. The reason that it's done like that is initial training is over three weeks so someone may be part of a cohort but not complete all training modules. They may then join a later cohort to complete modules they have missed."

To get you going with the most daunting question of database design - master-details, here is a short how to link the tables in Jam.py.

The database has a table staff which has a bunch of Details views, one of which is staff_cohorts (training classes) which links staff and cohorts in a many-to-many relationship:

Staff

On the design of the staff_cohorts details table I include a lookup to staff_number - this will effectively be a duplicate of the value of master_rec_id as above (shown in red). I also use this to then include all the things from the staff table (and associated tables) I want to see from my cohorts view of the data as lookups bound to this (shown in green)

Staff Cohorts

To view the code below, open the Application Builder https://cohortstraining.herokuapp.com/builder.html and navigate to Project/Task/Groups/Forms, click on "Staff" table and "Client Module", than on "Cohorts" table, etc.

I hide all these extra fields from the View form and Edit forms of staff_cohorts

When I open the Edit form of staff_cohorts, I programmatically set the value of the staff_number field:

function on_edit_form_created(item) {
    var current_staff_id = task.staff.id.value;
    item.staff_number.value = current_staff_id;
}

On the cohorts table I don't have any details associated, instead I create the details view of the staff_cohorts using the following code:

function on_view_form_created(item) {

    item.table_options.height -= 350;
    item.sc = task.staff_cohorts.copy();
}


function on_after_scroll(item) {
if (item.view_form.length) {
      if (item.rec_count) {
          item.sc.set_fields(['staff_number', 'first_name', 'surname', 'role',
          'department', 'master_id', 'master_rec_id', 'id', 'deleted']);
          item.sc.set_order_by(['surname']);
          item.sc.set_where({cohort_index: item.id.value});
          item.sc.create_table(item.view_form.find('.view-detail'), {
              height: 300,
              multiselect: true,
              select_all: true,
              summary_fields: ['staff_number'],
          });
          item.sc.open(true);
      }
      else {
          item.sc.close();
      }
    }
}


function on_view_form_shown(item) {
    item.refresh_page();  //fixes slightly annoying render bug
}

The render bug is that the column sizing doesn't auto-correct until you first scroll, the refresh fixes that.

About Jam.py Application Builder

Please visit for more info about the Jam.py:

http://jampyapplicationbuilder.com/

and more Demos:

https://jampy-aliases.herokuapp.com

https://redhatsatellite.herokuapp.com

https://sambashares.herokuapp.com/

https://jampy.pythonanywhere.com

How to run the App in your environment?

Open https://cohortstraining.herokuapp.com/builder.html , click on Project/Export. The downloaded file will be used for below Import. This procedure is applicable for any of above Demo Applications.

Jam.py Installation

Dependencies

  • python 2.7 // python 3.x
  • For MySQL database access: mysqlclient, libmysqlclient-dev
  • For Oracle database access: cx_oracle
  • For Firebird database access: fdb
  • For Jam.py Reports editing/creation: LibreOffice

Installing an official release with pip

The easiest is to use the standalone pip installer.

If you’re using Linux, Mac OS X or some other flavor of Unix, enter the command:

sudo pip install jam.py 

at the shell prompt. If you’re using Windows, start a command shell with administrator privileges and run the command:

pip install jam.py

This will install Jam.py in your Python installation’s site-packages directory.

Installing an official release manually

Download the package archive from https://github.com/jam-py/jam-py/tree/master

Create a new directory and unzip the archive there.

From the above directory, enter the command:

sudo python setup.py install

This will install Jam.py in your Python installation’s site-packages directory.

Running the Demo App

Navigate to jam.py installation demo folder, enter the command:

python server.py

You'll have the Demo App running at http://localhost:8080

Create a new App from above Export file

mkdir newapp
cd newapp
jam-project.py
python server.py

The new and empty App will run at http://localhost:8080

Please visit http://jam-py.com/docs/intro/index.html for complete Getting Started Introduction and Import of above file.

Hopefully this helps!

License MIT, free to use.

About

Cohorts Training

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published