[opw-web] Add the ability to edit contracts through the user interface



commit df50b9abe37a49b7a52ab36da59646a8387e6e55
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue May 12 16:35:26 2015 -0400

    Add the ability to edit contracts through the user interface
    
    Add a "contracts" database table which holds the text of contracts
    (both mentor and student) for each program. When viewing contracts,
    the most recent contract for the program is saved, but when the user
    accepts the contract, the actual revision that they accepted is
    recorded and shown back to them when they view the contract.
    
    Add a basic edit screen that is accessible with links from the
    screen to edit the program.

 lang/en-gb.php                                     |    7 +-
 modules/mod_contract.php                           |  208 ++++++++++++++-----
 modules/mod_manage_programs.php                    |    4 +
 schema.sql                                         |   21 ++-
 skins/easterngreen/css/main.css                    |   10 +
 skins/easterngreen/html/tpl_contract.html          |  150 +-------------
 skins/easterngreen/html/tpl_edit_contract.html     |   15 ++
 .../html/tpl_manage_programs_editor.html           |   16 ++
 8 files changed, 233 insertions(+), 198 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 59111be..3c6ffea 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -109,6 +109,9 @@ $lang_data = array(
     'active'                => 'Active',
     'start_date'            => 'Start date',
     'end_date'              => 'End date',
+    'student_contract'      => 'Intern contract',
+    'mentor_contract'       => 'Mentor contract',
+    'sample_contract_link'  => 'Link to sample contract',
     'dl_student'            => 'Application deadline',
     'dl_mentor'             => 'Selection deadline',
     'show_deadlines'        => 'Show deadlines',
@@ -363,6 +366,8 @@ $lang_data = array(
     'review_contract_notice_student'   => 'Please review the following terms of participation as an intern 
in Outreachy. If they are acceptable to you, please click on "Accept contract" at the bottom of the page.',
     'review_contract_notice_mentor'    => 'Please review the following terms of participation as a mentor in 
Outreachy. If they are acceptable to you, please click on "Accept contract" at the bottom of the page.',
     'view_contract_notice'      => 'You accepted the following contract on: ',
-    'accept_contract'           => "Accept contract"
+    'accept_contract'           => "Accept contract",
+
+    'edit_contract'             => "Edit contract"
 );
 
diff --git a/modules/mod_contract.php b/modules/mod_contract.php
index 0ee0f6a..c8a4895 100644
--- a/modules/mod_contract.php
+++ b/modules/mod_contract.php
@@ -7,77 +7,175 @@
 
 if (!defined('IN_PANDORA')) exit;
 
+require_once 'Michelf/Markdown.inc.php';
+
 $program_id = $core->variable('prg', 0);
 $return_url = $core->variable('r', '');
-$action = $core->variable('a', '');
-$accept_contract = isset($_POST['accept_contract']);
-
-if ($action == 'sample_student' || $action == 'sample_mentor') {
-    $is_sample = true;
-    $is_student = $action == 'sample_student';
-    $is_mentor = $action == 'sample_mentor';
-    $contract_accepted_time =  0;
-} else {
-    $is_sample = false;
-    $user->restrict(!is_null($user->username));
-    $username = $user->username;
+$action = $core->variable('a', '')
+;
+$program_data = $cache->get_program_data($program_id);
+
+$user->restrict($program_data != null);
 
-    $program_data = $cache->get_program_data($program_id);
+function escapenewlines($text) {
+    $text = str_replace("\n", "&#10;", $text);
+    $text = str_replace("\r", "&#13;", $text);
+    return $text;
+}
 
-    $user->restrict($program_data != null);
+if ($action == 'edit_student' || $action == 'edit_mentor') {
+    $user->restrict($user->is_admin);
 
-    $sql = "SELECT r.*, " .
-           "EXISTS (SELECT * from {$db->prefix}participants prt " .
-                   "LEFT JOIN {$db->prefix}projects prj " .
-                          "ON prj.id = prt.project_id " .
-                   "WHERE prt.program_id = r.program_id AND prt.username = r.username AND prj.is_accepted = 
1) as has_project " .
-           "FROM {$db->prefix}roles r " .
-               "WHERE r.username = :username " .
-               "AND r.program_id = :program_id";
+    $is_student = $action == 'edit_student';
+    $is_mentor = $action == 'edit_mentor';
+    $markdown = $core->variable('markdown', '');
 
-    $role_data = $db->query($sql,
-                            array('username' => $username,
-                                  'program_id' => $program_id),
-                            true);
+    if ($markdown != '') {
+        $is_preview = true;
+    } else {
+        $is_preview = false;
 
+        $sql = "SELECT contents from {$db->prefix}contracts " .
+                "WHERE program_id = :program_id AND role = :role " .
+                "ORDER BY id DESC";
 
-    $user->restrict($role_data['has_project']);
+        $row = $db->query($sql,
+                          array('program_id' => $program_id,
+                                'role' => $is_student ? 's' : 'm'),
+                          true);
+        $markdown = $row['contents'];
+    }
 
-    $is_student = $role_data['role'] == 's';
-    $is_mentor = $role_data['role'] == 'm';
-    $contract_accepted_time =  $role_data['contract_accepted_time'];
-}
+    $save_contract = isset($_POST['save_contract']);
 
-$has_accepted = $contract_accepted_time != 0;
+    if ($save_contract) {
+        $user->check_csrf();
 
-if ($accept_contract == 'accept') {
-    $user->check_csrf();
+        $is_preview = false;
 
-    if (!$is_sample) {
-        $sql = "UPDATE {$db->prefix}roles " .
-                  "SET contract_accepted_time = UNIX_TIMESTAMP() " .
-                "WHERE username = :username " .
-                  "AND program_id = :program_id";
+        $sql = "INSERT INTO {$db->prefix}contracts (program_id, role, uploader, upload_time, contents) " .
+               "VALUES (:program_id, :role, :username, UNIX_TIMESTAMP(), :contents)";
 
         $db->query($sql,
-                   array('username' => $username,
-                         'program_id' => $program_id));
+                   array('program_id' => $program_id,
+                         'role' => $is_student ? 's' : 'm',
+                         'username' => $user->username,
+                         'contents' => $markdown)
+                  );
+
+        if ($return_url != '')
+            $core->redirect($return_url);
     }
 
-    if ($return_url != '')
-        $core->redirect($return_url);
-}
+    $html = Michelf\Markdown::defaultTransform($markdown);
+
+    $skin->assign(array(
+         'program_mentor_visibility' => $skin->visibility($is_mentor),
+         'program_student_visibility' => $skin->visibility($is_student),
+         'preview_visibility' => $skin->visibility($is_preview),
+         'title'      => $program_data['title'],
+         'markdown'   => escapenewlines($markdown),
+         'html'       => $html,
+                 ));
+
+    // Output the module
+    $module_title = $lang->get('edit_contract');
+    $module_data = $skin->output('tpl_edit_contract');
+} else {
+    $accept_contract = isset($_POST['accept_contract']);
+
+    if ($action == 'sample_student' || $action == 'sample_mentor') {
+        $is_sample = true;
+        $is_student = $action == 'sample_student';
+        $is_mentor = $action == 'sample_mentor';
+        $contract_accepted_time =  0;
+        $contract_id = NULL;
+    } else {
+        $is_sample = false;
+        $user->restrict(!is_null($user->username));
+        $username = $user->username;
+
+        $sql = "SELECT r.*, " .
+               "EXISTS (SELECT * from {$db->prefix}participants prt " .
+                       "LEFT JOIN {$db->prefix}projects prj " .
+                              "ON prj.id = prt.project_id " .
+                       "WHERE prt.program_id = r.program_id AND prt.username = r.username AND 
prj.is_accepted = 1) as has_project " .
+               "FROM {$db->prefix}roles r " .
+                   "WHERE r.username = :username " .
+                   "AND r.program_id = :program_id";
+
+        $role_data = $db->query($sql,
+                                array('username' => $username,
+                                      'program_id' => $program_id),
+                                true);
+
+
+        $user->restrict($role_data['has_project']);
+
+        $is_student = $role_data['role'] == 's';
+        $is_mentor = $role_data['role'] == 'm';
+        $contract_accepted_time =  $role_data['contract_accepted_time'];
+    }
 
-$skin->assign(array(
-     'view_visibility'   => $skin->visibility($has_accepted),
-     'review_visibility' => $skin->visibility(!$has_accepted),
-     'program_mentor_visibility' => $skin->visibility($is_mentor),
-     'program_student_visibility' => $skin->visibility($is_student),
-     'contract_accepted_time' => date('M d, Y h:m:s', $contract_accepted_time)
-             ));
-
-// Output the module
-$module_title = $lang->get('view_contract');
-$module_data = $skin->output('tpl_contract');
+    $has_accepted = $contract_accepted_time != 0;
+
+    if ($has_accepted) {
+        $contract_id = $role_data['contract_id'];
+
+        $sql = "SELECT contents from {$db->prefix}contracts " .
+               "WHERE id = :contract_id";
+
+        $row = $db->query($sql,
+                          array('contract_id' => $contract_id),
+                          true);
+        $contract_contents = $row['contents'];
+    } else {
+        $sql = "SELECT id, contents from {$db->prefix}contracts " .
+                "WHERE program_id = :program_id AND role = :role " .
+                "ORDER BY id DESC";
+
+        $row = $db->query($sql,
+                          array('program_id' => $program_id,
+                                'role' => $is_student ? 's' : 'm'),
+                          true);
+        $contract_id = $row['id'];
+        $contract_contents = $row['contents'];
+    }
+
+    if ($accept_contract) {
+        $user->check_csrf();
+
+        if (!$is_sample) {
+            $sql = "UPDATE {$db->prefix}roles " .
+                      "SET contract_accepted_time = UNIX_TIMESTAMP(), " .
+                      "    contract_id = :contract_id " .
+                    "WHERE username = :username " .
+                      "AND program_id = :program_id";
+
+            $db->query($sql,
+                       array('username' => $username,
+                             'program_id' => $program_id,
+                             'contract_id' => $contract_id));
+        }
+
+        if ($return_url != '')
+            $core->redirect($return_url);
+    }
+
+    $contract_html = Michelf\Markdown::defaultTransform($contract_contents);
+
+    $skin->assign(array(
+         'view_visibility'   => $skin->visibility($has_accepted),
+         'review_visibility' => $skin->visibility(!$has_accepted),
+         'program_mentor_visibility' => $skin->visibility($is_mentor),
+         'program_student_visibility' => $skin->visibility($is_student),
+         'contract_accepted_time' => date('M d, Y h:m:s', $contract_accepted_time),
+         'contract_html' => $contract_html,
+                 ));
+
+    // Output the module
+    $module_title = $lang->get('view_contract');
+    $module_data = $skin->output('tpl_contract');
+}
 
 ?>
diff --git a/modules/mod_manage_programs.php b/modules/mod_manage_programs.php
index a9baad3..6a5d9cc 100644
--- a/modules/mod_manage_programs.php
+++ b/modules/mod_manage_programs.php
@@ -189,6 +189,10 @@ else if ($action == 'editor')
         'end_date'          => $end_date,
         'dl_student'        => $dl_student,
         'dl_mentor'         => $dl_mentor,
+        'student_contract_edit' => "?q=contract&amp;a=edit_student&amp;prg={$id}",
+        'student_contract_sample' => "?q=contract&amp;a=sample_student&amp;prg={$id}",
+        'mentor_contract_edit' => "?q=contract&amp;a=edit_mentor&amp;prg={$id}",
+        'mentor_contract_sample' => "?q=contract&amp;a=sample_mentor&amp;prg={$id}",
         'active_checked'    => $skin->checked($active == 1),
         'error_message'     => isset($error_message) ? $error_message : '',
         'error_visibility'  => $skin->visibility(isset($error_message)),
diff --git a/schema.sql b/schema.sql
index 234e14f..d32d44e 100644
--- a/schema.sql
+++ b/schema.sql
@@ -6,6 +6,7 @@ INSERT INTO `opw_cron` (
   `timestamp`
 ) VALUES (0);
 
+/* alter table opw_programs add `contract_id` mediumint(1) unsigned ; */
 CREATE TABLE `opw_programs` (
   `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
   `title` varchar(255) NOT NULL DEFAULT '',
@@ -15,7 +16,21 @@ CREATE TABLE `opw_programs` (
   `dl_student` int(11) unsigned NOT NULL,
   `dl_mentor` int(11) unsigned NOT NULL,
   `is_active` tinyint(1) NOT NULL DEFAULT 0,
+  `contract_id` mediumint(10) unsigned,
   PRIMARY KEY (`id`)
+  FOREIGN KEY (`contract_id`) REFERENCES `opw_contracts`(`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+CREATE TABLE `opw_contracts` (
+  `id` mediumint(10) unsigned NOT NULL AUTO_INCREMENT,
+  `program_id` mediumint(6) unsigned NOT NULL,
+  `role` char(1) NOT NULL DEFAULT 's',
+  `uploader` varchar(255) NOT NULL,
+  `upload_time` int(11) unsigned NOT NULL,
+  `contents` MEDIUMBLOB NOT NULL,
+  PRIMARY KEY (`id`),
+  FOREIGN KEY (`program_id`) REFERENCES `opw_programs`(`id`),
+  KEY (`program_id`, `id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 CREATE TABLE `opw_organizations` (
@@ -65,6 +80,8 @@ CREATE TABLE `opw_participants` (
 
 /* alter table opw_roles add `contract_approved` tinyint(1) NOT NULL DEFAULT 0 ; */
 /* alter table opw_roles add `contract_accepted_time` int(11) NOT NULL DEFAULT 0 ; */
+/* alter table opw_roles add `contract_id` mediumint(10) unsigned ; */
+/* alter table opw_roles add foreign key (`contract_id`) references opw_contracts(id) ; */
 CREATE TABLE `opw_roles` (
   `id` mediumint(10) NOT NULL AUTO_INCREMENT,
   `username` varchar(255) NOT NULL DEFAULT '',
@@ -73,9 +90,11 @@ CREATE TABLE `opw_roles` (
   `role` char(1) NOT NULL DEFAULT 's',
   `contract_approved` tinyint(1) NOT NULL DEFAULT 0,
   `contract_accepted_time` int(11) unsigned NOT NULL DEFAULT 0,
+  `contract_id` mediumint(10) unsigned,
   PRIMARY KEY (`id`),
   FOREIGN KEY (`program_id`) REFERENCES `opw_programs`(`id`),
-  FOREIGN KEY (`organization_id`) REFERENCES `opw_organizations`(`id`)
+  FOREIGN KEY (`organization_id`) REFERENCES `opw_organizations`(`id`),
+  FOREIGN KEY (`contract_id`) REFERENCES `opw_contracts`(`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 CREATE TABLE `opw_session` (
diff --git a/skins/easterngreen/css/main.css b/skins/easterngreen/css/main.css
index ae701be..0ded5cb 100644
--- a/skins/easterngreen/css/main.css
+++ b/skins/easterngreen/css/main.css
@@ -198,6 +198,16 @@ h3 {
     padding: 5px 0px 0px 0px;
 }
 
+.contract-input {
+    width: 100%;
+    height: 300px;
+    font-family: monospace;
+}
+
+.contract-actions {
+    padding: 5px;
+}
+
 /*-----------------Links and images-----------------*/
 
 .learn-more {
diff --git a/skins/easterngreen/html/tpl_contract.html b/skins/easterngreen/html/tpl_contract.html
index 948731d..9d64c22 100644
--- a/skins/easterngreen/html/tpl_contract.html
+++ b/skins/easterngreen/html/tpl_contract.html
@@ -9,150 +9,18 @@
 <div class="alert [[view_visibility]]">
   {{view_contract_notice}} [[contract_accepted_time]]
 </div>
-<div class="[[program_mentor_visibility]]">
-</div>
+<div id="contractText" class="contract-text" onscroll="checkScroll()">[[contract_html]]</div>
+<div class="[[review_visibility]]">
+<button disabled id="acceptContractButton" type="submit" name="accept_contract"  class="btn btn-primary">
+    {{accept_contract}}
+</button>
 <script type="text/javascript">
-function checkScroll(e) {
-   if (e.target.scrollTop >= e.target.scrollHeight - e.target.clientHeight - 5) {
+function checkScroll() {
+   var scrollDiv = document.getElementById("contractText");
+   if (scrollDiv.scrollTop >= scrollDiv.scrollHeight - scrollDiv.clientHeight - 5) {
        document.getElementById("acceptContractButton").removeAttribute("disabled");
    }
 }
+checkScroll();
 </script>
-<div class="[[program_student_visibility]] contract-text" onscroll="checkScroll(event)">
-<p>OUTREACHY INTERNSHIP PROGRAM<br />
-Internship Terms of Participation<br />
-Last edited – May 1, 2015</p>
-
-<p>Dear Participant:</p>
-
-<p>Congratulations on your acceptance to the Outreachy internship program!  These Internship Terms of 
Participation (“ITOP”) will serve as the agreement between you and Conservancy concerning your participation 
in the Outreachy internship program (the “Program”).  In this agreement, the terms “you” and “your” means 
you, a person who has been accepted to the Program subject to the ITOP, and who is agreeing to be bound by 
the ITOP; and “Conservancy” means Software Freedom Conservancy, Inc., a New York non-profit corporation, US 
501(c)(3) public charity, and corporate home of the Outreachy Project.</p>
-
-<h2>The Project.</h2>
-<p>You agree to perform the Project as assigned to the Application you submitted to Conservancy (the 
“Application”).  Your project should be your primary focus during the duration of the Program and you should 
dedicate 40 hours per week to it.  From time to time, you will deliver work product related to your Project 
(“Project Work Product”) to your Participating Organization (as set out in the Application) through your 
Volunteer Mentor or Volunteer Mentors (if applicable, together referred to herein as the “Volunteer Mentor”) 
(as set out in the Application) or otherwise.  Please discuss with your Volunteer Mentor any adjustments that 
need to be made to your Project Work Product goals based on your progress with the project, interests, and 
current goals of the project team.</p>
-
-<p>While you retain any copyright or patent rights in the Project, you hereby license all submissions 
related to the Project under a license that is (i) approved by your Participating Organization, (ii) a Free 
Software license as designated by the Free Software Foundation, and (iii) an Open Source license as approved 
by the Open Source Initiative (“Project License”).</p>
-
-<p>Additionally, you agree to blog at least once every two weeks about your work. You hereby license each 
blog entry – and all other documentation you create for this Project – under the Creative Commons 
Attribution-ShareAlike 4.0 International License, and agree that it may be included on any site that 
aggregates blog posts of organization contributors.
-  .
-<p>You hereby represent, warrant and agree that all Project Work Product, blogs, and other work you complete 
related to the project:
-<ul>
-  <li>(a) are your own original, previously unpublished and unproduced work, except to the extent that it 
includes third party source code available for modification and redistribution under a license compatible 
with the Project License;</li>
-  <li>(b) are not submitted in violation of any agreement;</li>
-  <li>(c) do not infringe on any copyright, patent, trademark or applicable moral rights of any third 
party;</li>
-  <li>(d) do not violate any applicable laws and are not malicious, defamatory, libelous, pornographic, or 
obscene; and</li>
-  <li>(e) do not contain any confidential information.</li>
-</ul>
-
-<p>Your internship and all payments pursuant to this agreement are subject to there being a Volunteer Mentor 
assigned to your Application, who signs a Volunteer Mentor Agreement with Conservancy.  If there is no 
Volunteer Mentor Agreement received by Conservancy, no payments will be made. Please contact the 
Participating Organization coordinator if you become aware that your mentor will not enter into this 
agreement.</p>
-
-<h2Relationship of Parties.</h2>
-<p>It is expressly agreed that in your performance of the Project you will not be an employee or agent of 
Conservancy. It is also agreed that you shall have no right to make any commitments on behalf of Conservancy, 
or act as an agent of Conservancy. You also represent and warrant to Conservancy that neither your execution 
of this agreement nor your participation in the Program conflicts with any contractual commitment on your 
part.</p>
-
-<h2>Stipend.</h2>
-<p>Conservancy will pay you a $5,500 USD stipend (“Stipend”) for the Project in accordance with the 
following schedule, subject to Conservancy’s receipt of such funds from the relevant sponsor.  Participants 
will be in good standing if they have used their best efforts to complete their Project Work Product.</p>
-
-<p>Whether or not you are in good standing with your Volunteer Mentor is within the sole judgment of that 
Volunteer Mentor upon consultation with the Program coordinators.  You understand and agree that Conservancy 
does not have the ability to control, direct, or instruct the Volunteer Mentor’s judgment regarding your good 
standing.  You may request that the Program coordinators review the Volunteer Mentor's decision.</p>
-
-  FIXME DATE:  $500 will be sent to you if you have begun your Project.
-  FIXME DATE:  $2,250 will be sent to you if you are in good standing with your Volunteer Mentor.
-  FIXME DATE: $2,750 will be sent to you if your Volunteer Mentor has determined that you have successfully 
completed your internship.
-
-<p>In addition to being subject to your good standing, payment according to this schedule is subject to the 
timely receipt of appropriate tax documentation which you will provide to Conservancy as we may request.</p>
-
-<h2>Taxes, Insurance, Benefits and Business Expenses.</h2>
-<p>You shall be solely responsible for any workers' compensation insurance and unemployment insurance and 
for the withholding and payment of all federal and state income taxes and social security and Medicare taxes 
and other legally-required payments on sums received from Conservancy, including any foreign taxes, that may 
be required of you. You will also be solely responsible for any comprehensive general liability, automobile 
and other insurance and assume all risk in connection with the adequacy of any and all such insurance which 
you elect to obtain.</p>
-<p>Neither you nor any dependent or other individual claiming through you will be eligible to participate 
in, or receive benefits under, any of the employee benefit plans maintained by Conservancy.  You hereby waive 
all rights, if any, to participate in, or receive benefits under, any of Conservancy’s plans. You also agree 
never to make a claim under any of Conservancy’s plans and you agree to indemnify and hold Conservancy and 
its plans and all those connected with them harmless from all liabilities and expenses in any way arising out 
of any such claim by you or by anyone claiming through you.</p>
-<p> You shall be solely responsible for all expenses incurred by you in the performance of the Project.</p>
-<p>It is also agreed that Conservancy shall have no obligation whatsoever to compensate you on account of 
any damages or injuries that you may sustain as a result or in the course of the participation in the 
Program, except for any damages or injuries sustained by you that result from any negligence by 
Conservancy.</p>
-
-<h2>Warranties.</h2>
-<p>You hereby represent, warrant, and agree that:</p>
-<ul>
-  <li>(a) you (i) identify as a woman, (ii) were assigned female at birth, (iii) identify as genderqueer, 
genderfluid or genderfree regardless of gender presentation, or (iv) are or have been a participant in 
Mozilla's Project Ascend;</li>
-  <li>(b) you are eligible to work in the country or countries in which you will reside throughout the 
duration of the program;</li>
-  <li>(c) you (i) are not a resident or national of Cuba, Iran, North Korea, Syria, Sudan, or (ii) you have 
disclosed that you are a resident or national of Iran, North Korea, Syria, or Sudan, participating in the 
Program to Conservancy and are not currently residing in one of these countries;</li>
-  <li>(d) you are not a person or entity restricted by US export controls or sanctions programs;</li>
-  <li>(e) you are or will be 18 years of age or older by FIXME DATE.</li>
-</ul>
-
-<h2>Indemnification.</h2>
-<p>You shall indemnify, defend, and hold harmless Conservancy, its officers, directors, and employees from 
any and all claims, demands, damages, costs and liabilities, including reasonable attorneys’ fees, made by 
any third party due to or arising out of your gross negligence, recklessness, or intentional wrongdoing, 
including claims arising out of your participation in the Program; your Project Work Product (including 
publication of source code) or related correspondence (including with your Volunteer Mentor) or related 
blogs; or your violation of this Agreement.</p>
-
-<h2>Limitation of Liability.</h2>
-<p>You understand and agree that Conservancy does not and can not control the actions of other participants 
(including your Volunteer Mentor), and that in no event shall Conservancy, its officers, directors, 
employees, or suppliers be liable for any special, incidental or consequential damages arising out of or in 
connection with the Program (however arising, including negligence).</p>
-
-<p>In any event, Conservancy, its officers, directors, employees, or suppliers will not be liable to you in 
excess of the Stipend to be paid pursuant to this Agreement, by any reason of act or omission, including 
breach of contract or negligence not amounting to a willful or intentional wrong. You recognize and agree 
that without this limitation of liability Conservancy would not be able to offer this Program, which furthers 
Conservancy’s charitable purposes.</p>
-
-<h2>Termination.</h2>
-<p>The internship will take place between FIXME DATE and FIXME DATE and all of Conservancy’s obligations to 
you will terminate with the final payment on FIXME DATE.</p>
-
-<p>This Agreement and your participation may be terminated by Conservancy or you at any time, with or 
without cause, by written notice to the other party.  Upon termination of this Agreement, Conservancy shall 
have no further obligation to you, other than for payment in accordance with the Stipend section, above.</p>
-
-<h2>Miscellaneous.</h2>
-<p>Choice of Law.  Any action related to this Agreement will be governed by laws of the State of New York 
(except that body of law controlling conflict of laws). The parties hereby exclusively and irrevocably submit 
to, and waive any objection against the personal jurisdiction of the United States Southern District of New 
York, and the State Courts of the State of New York in Kings County.</h2>
-<p> Assignment.  This Agreement shall extend to and shall be binding upon the parties hereto, and their 
respective successors and assigns; provided however, that because the program is designed in part to help you 
learn how to apply your skills to Free and Open Source Software you may not assign or delegate this 
Agreement, or any rights, duties, or obligations without written approval by Conservancy.</p>
-<p>Severability. Any provision of this Agreement that is prohibited or unenforceable in any jurisdiction 
shall, as to such jurisdiction, be ineffective to the extent of such prohibition or unenforceability without 
invalidating the remaining provisions hereof, and any such prohibition or unenforceability in any 
jurisdiction shall (to the full extent permitted by law) not invalidate render unenforceable such provision 
in any other jurisdiction.</p>
-<p>
-Entire Agreement.  This letter contains the entire agreement between you and Conservancy,
-  and replaces all prior agreements, whether written or oral, with respect to the Program and all related 
matters. This agreement may not be amended or assigned and no breach may be waived unless agreed to in 
writing by you and Conservancy. In accepting this offer, you give Conservancy assurance that you have not 
relied on any agreements or representations, express or implied, that are not set forth expressly in this 
letter.
-</p>
-<p>If the ITOP are acceptable to you, please FIXME – (fill out the form and click on the “Accept” button 
below) by no later than FIXME DATE. At the time you sign and return it, this letter shall take effect as a 
legally-binding agreement between you and Conservancy on the basis set forth above.  Please download a copy 
of this agreement for your records.</p>
-</div>
-
-<div class="[[program_mentor_visibility]] contract-text" onscroll="checkScroll(event)">
-<p>OUTREACHY INTERNSHIP PROGRAM<br />
-Mentorship Terms of Participation<br />
-last edited – May 1, 2015<br />
-
-<p>Dear Participant:</p>
-
-<p>Thank you for agreeing to be a volunteer mentor for the Outreachy internship program!  These Mentorship 
Terms of Participation (“MTOP”) will serve as the agreement between you and Conservancy concerning your 
participation in the Outreachy internship program (the “Program”).  In this agreement, the terms “you” and 
“your” means you, a person who has agreed to be a Volunteer Mentor for the Program subject to MTOP, and who 
is agreeing to be bound by the MTOP; and “Conservancy” means Software Freedom Conservancy, Inc., a New York 
non-profit corporation, US 501(c)(3) public charity, and corporate home of the Outreachy Project.</p>
-
-<h2>Mentoring Activities.</h2>
-<p>In consideration for your participation in the Program, which serves a charitable purpose, you agree to 
act as Volunteer Mentor to one or more interns participating in the Program (“Intern”) in completion of the 
Project as set out in the Program application which each Intern submitted to Conservancy (the “Program 
Application”).  As Volunteer Mentor, you agree to (1) respond constructively and within a reasonable time to 
mentee correspondence and (2) provide updates from time to time to the Outreach Project regarding whether the 
Intern is in good standing (collectively, “Mentoring Activities”).</p>
-
-<h2>Relationship of Parties.</h2>
-<p>It is expressly agreed that, in performing the Mentoring Activities, you will be a volunteer and that you 
will not be an employee or agent of Conservancy. It is also agreed that you shall have no right to make any 
commitments on behalf of Conservancy.</p>
-
-<h2>Taxes, Insurance, Benefits and Business Expenses.</h2>
-<p>Because you are a volunteer, neither you nor any dependent or other individual claiming
-through you will be eligible to participate in, or receive benefits under, any of the employee
-benefit plans maintained by Conservancy. You hereby waive all rights, if any, to participate in, or receive 
benefits under, any of the Conservancy plans. You also agree never to make a claim under any of Conservancy’s 
plans and you agree to indemnify and hold Conservancy and its plans and all those connected with them 
harmless from all liabilities and expenses in any way arising out of any such claim by you or by anyone 
claiming through you.  Also, as a volunteer, you shall be solely responsible for all expenses incurred by you 
in the performance of the Mentoring Activities.</p>
-
-<h2>Warranties.</h2>
-<p>You hereby represent, warrant, and agree that:</p>
-<ul>
-<li>(a) you are an active participant in the free and open source software project set forth in the Program 
Application;</li>
-<li>(b) you are not a resident or national of Cuba, Iran, North Korea, Syria, or Sudan;</li>
-<li>(c) you are not a person or entity restricted by US export controls or sanctions programs; and</li>
-<li>(d) you are or will be 18 years of age or older by FIXME DATE.</li>
-</ul>
-
-<h2>Indemnification.</h2>
-<p>We expect mentors in all our participating projects to treat Interns with respect and to fill the role of 
mentor as best as they can. We encourage you to familiarize yourself with any Code of Conduct adopted by your 
organization. Because Conservancy is the legal entity responsible for this Program and because Volunteer 
Mentors are independently responsible for a large portion of how the Program is run, we ask for a limited 
indemnification. For only situations arising out of your gross negligence, recklessness or intentional 
wrongdoing, you shall indemnify, defend, and hold harmless Conservancy, its officers, directors, and 
employees from any and all claims, demands, damages, costs and liabilities, including reasonable attorneys’ 
fees, made by any third party due to or arising out of your participation in the Program; your Mentoring 
Activities (including correspondence with the Participant or Participants, and modification of any 
Participant’s source code or written ma
 terials); or your violation of this Agreement.</p>
-
-<h2>Limitation of Liability.</h2>
-<p>You understand and agree that Conservancy does not and can not control the actions of other Program 
participants (including the Intern), and that in no event shall Conservancy, its officers, directors, 
employees, or suppliers be liable for any special, incidental or consequential damages arising out of or in 
connection with the Program (however arising, including negligence).</p>
-
-<p>In any event, Conservancy, its officers, directors, employees, or suppliers will not be liable to you by 
any reason of act or omission, including breach of contract or negligence not amounting to a willful or 
intentional wrong. You recognize, understand, and agree that without this limitation of liability Conservancy 
would not be able to offer this Program, which furthers Conservancy’s charitable purposes.</p>
-
-<h2>Termination.</h2>
-<p>Internships in the Program will take place between FIXME DATE and FIXME DATE, with final payment to 
successful Interns on FIXME DATE.  The MTOP and your services may be terminated by Conservancy or you at any 
time, with or without cause, by written notice to the  other party. Upon termination of this Agreement, 
Conservancy shall have no further obligation to you.</p>
-
-<h2>Miscellaneous.</h2>
-<p><i>Choice of Law.</i>  Any action related to this Agreement will be governed by laws of the State of New 
York (except that body of law controlling conflict of laws). The parties hereby exclusively and irrevocably 
submit to, and waive any objection against the personal jurisdiction of the United States Southern District 
of New York, and the State Courts of the State of New York in Kings County.</p>
-
-<p><i>Assignment.</i>  This Agreement shall extend to and shall be binding upon the parties hereto, and 
their respective successors and assigns; provided however, that because the program is designed in part to 
help you learn how to apply your skills to Free and Open Source Software you may not assign or delegate this 
Agreement, or any rights, duties, or obligations without written approval by Conservancy.</p>
-
-<p><i>Severability.</i> Any provision of this Agreement that is prohibited or unenforceable in any 
jurisdiction shall, as to such jurisdiction, be ineffective to the extent of such prohibition or 
unenforceability without invalidating the remaining provisions hereof, and any such prohibition or 
unenforceability in any jurisdiction shall (to the full extent permitted by law) not invalidate render 
unenforceable such provision in any other jurisdiction.</p>
-
-<p><i>Entire Agreement.</.i>  This letter contains the entire agreement between you and Conservancy, and 
replaces all prior agreements, whether written or oral, with respect to the Program and all related matters. 
This agreement may not be amended or assigned and no breach may be waived unless agreed to in writing by you 
and Conservancy. In accepting this offer, you give Conservancy assurance that you have not relied on any 
agreements or representations, express or implied, that are not set forth expressly in this letter.</p>
-
-<p>If the MTOP are acceptable to you, please FIXME – (fill out the form and click on the “Accept” button 
below) by no later than FIXME DATE. At the time you sign and return it, this letter shall take effect as a 
legally-binding agreement between you and Conservancy on the basis set forth above.  Please download a copy 
of this agreement for your records.</p>
-  </div>
-
-<div class="[[review_visibility]]">
-<button disabled id="acceptContractButton" type="submit" name="accept_contract"  class="btn btn-primary">
-    {{accept_contract}}
-</button>
 </div>
diff --git a/skins/easterngreen/html/tpl_edit_contract.html b/skins/easterngreen/html/tpl_edit_contract.html
new file mode 100644
index 0000000..cbc2e8f
--- /dev/null
+++ b/skins/easterngreen/html/tpl_edit_contract.html
@@ -0,0 +1,15 @@
+<h2 class="[[program_student_visibility]]">Intern contract - [[title]]</h2>
+<h2 class="[[program_mentor_visibility]]">Mentor contract - [[title]]</h2>
+<div class="alert alert-info [[preview_visibility]]">
+    This is a preview and not yet saved.
+</div>
+<p>Please enter the text of the contract below using <a 
href="http://daringfireball.net/projects/markdown/syntax";>Markdown</a> syntax</p>
+<textarea class="contract-input" name="markdown">[[markdown]]</textarea>
+<div class="contract-actions">
+<button type="submit" name="prveiew_contract" class="btn">Preview</button>&nbsp;
+<button type="submit" name="save_contract"  class="btn btn-primary">Save</button>
+</div>
+<h2>Formatted result</h2>
+<div class="contract-text" onscroll="checkScroll(event)">
+  [[html]]
+</div>
diff --git a/skins/easterngreen/html/tpl_manage_programs_editor.html 
b/skins/easterngreen/html/tpl_manage_programs_editor.html
index 4518b82..3ff6570 100644
--- a/skins/easterngreen/html/tpl_manage_programs_editor.html
+++ b/skins/easterngreen/html/tpl_manage_programs_editor.html
@@ -53,6 +53,22 @@
 </div>
 
 <div class="control-group">
+    <label class="control-label">{{mentor_contract}}</label>
+    <div class="controls">
+        <a href="[[student_contract_edit]]" target="edit_contract">{{edit_contract}}</a><br />
+        <a href="[[student_contract_sample]]" target="sample_contract">{{sample_contract_link}}</a>
+    </div>
+</div>
+
+<div class="control-group">
+    <label class="control-label">{{student_contract}}</label>
+    <div class="controls">
+        <a href="[[mentor_contract_edit]]" target="edit_contract">{{edit_contract}}</a><br />
+        <a href="[[mentor_contract_sample]]" target="sample_contract">{{sample_contract_link}}</a>
+    </div>
+</div>
+
+<div class="control-group">
     <label class="control-label">{{active}} &nbsp;</label>
     <div class="controls">
         <input type="checkbox" name="active" [[active_checked]] />



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]