jenkins-bot has submitted this change and it was merged.

Change subject: Add a 'description' field to Queries
......................................................................


Add a 'description' field to Queries

Change-Id: I7631a3fa78c3f8a219a0ce5c6f3da866fcbe131d
---
M quarry/web/app.py
M quarry/web/models/query.py
M quarry/web/static/css/query/view.css
M quarry/web/static/js/query/view.js
M quarry/web/templates/query/view.html
M tables.sql
6 files changed, 25 insertions(+), 1 deletion(-)

Approvals:
  Yuvipanda: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/quarry/web/app.py b/quarry/web/app.py
index 2a5ee10..11f7e12 100644
--- a/quarry/web/app.py
+++ b/quarry/web/app.py
@@ -234,6 +234,8 @@
         query.title = request.form['title']
     if 'published' in request.form:
         query.published = request.form['published'] == '1'
+    if 'description' in request.form:
+        query.description = request.form['description']
     g.session.add(query)
     g.session.commit()
     return json.dumps({'id': query.id})
diff --git a/quarry/web/models/query.py b/quarry/web/models/query.py
index 38b7037..d2ab9e9 100644
--- a/quarry/web/models/query.py
+++ b/quarry/web/models/query.py
@@ -1,4 +1,4 @@
-from sqlalchemy import Column, Integer, ForeignKey, Unicode, DateTime, Boolean
+from sqlalchemy import Column, Integer, ForeignKey, Unicode, DateTime, 
Boolean, UnicodeText
 from sqlalchemy.orm import relationship
 from base import Base
 from user import User  # noqa
@@ -14,6 +14,7 @@
     parent_id = Column(Integer)
     latest_rev_id = Column(Integer, ForeignKey('query_revision.id'))
     published = Column(Boolean)
+    description = Column(UnicodeText)
 
     # Stick with "rev" as common language.
     revs = relationship('QueryRevision',
diff --git a/quarry/web/static/css/query/view.css 
b/quarry/web/static/css/query/view.css
index 7b40c6f..951fa9f 100644
--- a/quarry/web/static/css/query/view.css
+++ b/quarry/web/static/css/query/view.css
@@ -62,3 +62,9 @@
 .edit .only-no-edit {
     display: none;
 }
+
+#query-description {
+    border: none;
+    width: 100%;
+    resize: none;
+}
diff --git a/quarry/web/static/js/query/view.js 
b/quarry/web/static/js/query/view.js
index bd51e87..79d7388 100644
--- a/quarry/web/static/js/query/view.js
+++ b/quarry/web/static/js/query/view.js
@@ -36,6 +36,15 @@
         });
     });
 
+    $("#query-description").blur( function() {
+        $.post( "/api/query/meta", {
+            query_id: vars.query_id,
+            description: $("#query-description").val()
+        } ).done( function() {
+            // Uh, do nothing?
+        } );
+    } );
+
     $("#toggle-publish").click( function() {
         $.post( "/api/query/meta", {
             query_id: vars.query_id,
diff --git a/quarry/web/templates/query/view.html 
b/quarry/web/templates/query/view.html
index faf8663..818e48f 100644
--- a/quarry/web/templates/query/view.html
+++ b/quarry/web/templates/query/view.html
@@ -39,6 +39,11 @@
         {% endif %}
     </div>
     <div>
+        {% if jsvars.can_edit or query.description %}
+        <textarea id="query-description" {% if jsvars.can_edit 
%}placeholder="Click to add description..."{% else %}readonly{% endif %}>{% if 
query.description %}{{query.description}}{% endif %}</textarea>
+        {% endif %}
+    </div>
+    <div>
         <h3>SQL</h3>
         <textarea id="code">{% if latest_rev %}{{ latest_rev.text 
}}{%endif%}</textarea>
     </div>
diff --git a/tables.sql b/tables.sql
index b41d643..d993819 100644
--- a/tables.sql
+++ b/tables.sql
@@ -15,6 +15,7 @@
     latest_rev_id INT UNSIGNED,
     last_touched TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE 
CURRENT_TIMESTAMP,
     published SMALLINT DEFAULT 0,
+    description TEXT BINARY,
     parent_id INT UNSIGNED
 );
 CREATE INDEX query_parent_id_index ON query(parent_id);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7631a3fa78c3f8a219a0ce5c6f3da866fcbe131d
Gerrit-PatchSet: 1
Gerrit-Project: analytics/quarry/web
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to