Pārlūkot izejas kodu

[spark] Add description field to the notebook

Romain Rigaux 10 gadi atpakaļ
vecāks
revīzija
2b8bb40fad

+ 1 - 0
apps/spark/src/spark/api.py

@@ -152,6 +152,7 @@ def save_notebook(request):
 
   notebook_doc.update_data(notebook)
   notebook_doc.name = notebook['name']
+  notebook_doc.description = notebook['description']
   notebook_doc.save()
 
   response['status'] = 0

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 3 - 1
apps/spark/src/spark/fixtures/initial_spark_examples.json


+ 5 - 1
apps/spark/src/spark/management/commands/spark_setup.py

@@ -25,6 +25,8 @@ from django.core.management.base import BaseCommand
 from django.utils.translation import ugettext as _
 
 from desktop.models import Document
+from useradmin.models import install_sample_user
+
 
 LOG = logging.getLogger(__name__)
 
@@ -39,7 +41,9 @@ class Command(BaseCommand):
     else:
       user = options['user']
 
-    management.call_command('loaddata', 'initial_spark_examples.json', verbosity=2)
+    install_sample_user()
+
+    management.call_command('loaddata', 'apps/spark/src/spark/fixtures/initial_spark_examples.json', verbosity=2)
     Document.objects.sync()
 
     from beeswax.management.commands.beeswax_install_examples import Command

+ 1 - 0
apps/spark/src/spark/models.py

@@ -62,6 +62,7 @@ class Notebook():
     else:
       self.data = json.dumps({
           'name': 'My Notebook',
+          'description': '',
           'snippets': []
       })
 

+ 1 - 0
apps/spark/src/spark/static/spark/js/spark.ko.js

@@ -519,6 +519,7 @@ var Notebook = function (vm, notebook) {
   self.id = ko.observable(typeof notebook.id != "undefined" && notebook.id != null ? notebook.id : null);
   self.uuid = ko.observable(typeof notebook.uuid != "undefined" && notebook.uuid != null ? notebook.uuid : UUID());
   self.name = ko.observable(typeof notebook.name != "undefined" && notebook.name != null ? notebook.name : 'My Notebook');
+  self.description = ko.observable(typeof notebook.description != "undefined" && notebook.description != null ? notebook.description: '');
   self.snippets = ko.observableArray();
   self.selectedSnippet = ko.observable(vm.availableSnippets()[0].type());
   self.sessions = ko.mapping.fromJS(typeof notebook.sessions != "undefined" && notebook.sessions != null ? notebook.sessions : []);

+ 1 - 1
apps/spark/src/spark/views.py

@@ -39,7 +39,7 @@ def editor(request):
   notebook_id = request.GET.get('notebook')
 
   if notebook_id:
-    notebook = Notebook(document=Document2.objects.get(id=notebook_id)) # Todo perms
+    notebook = Notebook(document=Document2.objects.get(id=notebook_id))
   else:
     notebook = Notebook()
 

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels