Milimetric has submitted this change and it was merged.

Change subject: this should be a functioning cohort upload
......................................................................


this should be a functioning cohort upload

Change-Id: I50e7a1a2066fce7ce520198583ec24b6208f75f8
---
M wikimetrics/controllers/cohorts.py
M wikimetrics/templates/csv_upload_form.html
M wikimetrics/templates/csv_upload_review.html
M wikimetrics/templates/index.html
4 files changed, 21 insertions(+), 8 deletions(-)

Approvals:
  Milimetric: Verified; Looks good to me, approved



diff --git a/wikimetrics/controllers/cohorts.py 
b/wikimetrics/controllers/cohorts.py
index 767d4f8..9f01f1f 100644
--- a/wikimetrics/controllers/cohorts.py
+++ b/wikimetrics/controllers/cohorts.py
@@ -130,6 +130,7 @@
             csv_file = request.files['csv']
             name = request.form['name']
             project = request.form['project']
+            description = request.form['description']
             if not csv_file or not name or len(name) is 0:
                 flash('The form was invalid, please select a file and name the 
cohort.', 'error')
                 return redirect(url_for('cohort_upload'))
@@ -150,6 +151,7 @@
                 invalid_json=to_safe_json(invalid),
                 name=name,
                 project=project,
+                description=description,
             )
         except Exception, e:
             logging.exception(str(e))
@@ -166,6 +168,7 @@
     try:
         name = request.form.get('name')
         project = request.form.get('project')
+        description = request.form.get('description')
         users_json = request.form.get('users')
         users = json.loads(users_json)
         # re-validate
@@ -185,7 +188,7 @@
             if all([user['project'] == users[0]['project'] for user in users]):
                 project = users[0]['project']
         logging.debug('adding cohort: {0}, with project: {1}'.format(name, 
project))
-        cohort = create_cohort(name, 'TODO: add description', project, valid)
+        cohort = create_cohort(name, description, project, valid)
         return json_redirect(url_for('cohorts_list'))
         
     except Exception, e:
@@ -200,6 +203,7 @@
         name=name,
         default_project=project,
         description=description,
+        enabled=True,
     )
     db_session.add(cohort)
     db_session.commit()
@@ -207,13 +211,14 @@
     cohort_owner = CohortUser(
         cohort_id=cohort.id,
         user_id=current_user.id,
+        role=CohortUserRole.OWNER,
     )
     db_session.add(cohort_owner)
     
     wikiusers = []
     for valid_user in valid_users:
         wikiuser = WikiUser(
-            mediawiki_userid=valid_user['userid'],
+            mediawiki_userid=valid_user['user_id'],
             mediawiki_username=valid_user['username'],
         )
         wikiusers.append(wikiuser)
diff --git a/wikimetrics/templates/csv_upload_form.html 
b/wikimetrics/templates/csv_upload_form.html
index 09b9c5c..716f8cb 100644
--- a/wikimetrics/templates/csv_upload_form.html
+++ b/wikimetrics/templates/csv_upload_form.html
@@ -3,13 +3,19 @@
         <h3>Create a Cohort by Uploading a CSV</h3>
     </div>
     <div class="control-group">
-        <label for="name" class="control-label">Cohort Name</label>
+        <label for="name" class="control-label">Name</label>
         <div class="controls">
             <input type="text" name="name" id="name" value="{% if name 
%}{{name}}{% endif %}"/>
             <label for="name">(automatically checks availability)</label>
         </div>
     </div>
     <div class="control-group">
+        <label for="description" class="control-label">Description</label>
+        <div class="controls">
+            <textarea rows="4" cols="50" name="description" 
id="description">{% if description %}{{description}}{% endif %}</textarea>
+        </div>
+    </div>
+    <div class="control-group">
         <label for="project" class="control-label">Default Project</label>
         <div class="controls">
             <input type="text" name="project" id="project" value="{% if 
project %}{{project}}{% endif %}"/>
diff --git a/wikimetrics/templates/csv_upload_review.html 
b/wikimetrics/templates/csv_upload_review.html
index 4381436..b81de40 100644
--- a/wikimetrics/templates/csv_upload_review.html
+++ b/wikimetrics/templates/csv_upload_review.html
@@ -57,11 +57,13 @@
 <script src="{{ url_for('static', filename='js/cohortUpload.js') }}"></script>
 <script>
     // TODO: get this nasty stuff out of here
+    var desc = '{{ description | replace("\n", "\\n") | replace("\r", "\\r") 
}}';
     var from_the_server = {
-        invalid : JSON.parse('{{ invalid_json | safe }}'),
-        valid   : JSON.parse('{{ valid_json | safe }}'),
-        name    : '{{ name }}',
-        project : '{{ project }}',
+        invalid     : JSON.parse('{{ invalid_json | safe }}'),
+        valid       : JSON.parse('{{ valid_json | safe }}'),
+        name        : '{{ name }}',
+        project     : '{{ project }}',
+        description : desc
     };
 </script>
 <script src="{{ url_for('static', filename='js/cohortReview.js') }}"></script>
diff --git a/wikimetrics/templates/index.html b/wikimetrics/templates/index.html
index 67497df..2108ea2 100644
--- a/wikimetrics/templates/index.html
+++ b/wikimetrics/templates/index.html
@@ -55,7 +55,7 @@
         <h4>Your <a href="{{url_for('jobs_index')}}">jobs</a></h4>
         <ul data-bind="foreach: jobs">
             <li>
-                <span data-bind="text: moment(created).format('YYYY-MM-DD 
HH:mm')"></span> - 
+                <strong data-bind="text: 
moment.unix(created).calendar()"></strong> - 
                 <span data-bind="text: name"></span>
             </li>
         </ul>

-- 
To view, visit https://gerrit.wikimedia.org/r/74163
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I50e7a1a2066fce7ce520198583ec24b6208f75f8
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>
Gerrit-Reviewer: Milimetric <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to