@@ -15,19 +15,25 @@ def __init__(self):
1515 self .activities = TinyDB ("data/activities.json" )
1616 self .query = Query ()
1717
18- def load (self , name ):
19- return self .activities .search (self .query .name == name )[0 ]
18+ def load (self , name , default ):
19+ if name :
20+ return self .activities .search (self .query .name == name )[0 ]
21+ elif default is not None :
22+ return self .activities .search (self .query .default == True )[0 ]
2023
2124 def save (self , activity ):
2225 if self .activities .search (self .query .name == activity ["name" ]) == []:
2326 self .activities .insert (activity )
2427 else :
28+ if activity ["default" ] == True :
29+ default_activity = self .load (None , True )
30+ default_activity ["default" ] = False
31+ self .activities .update (default_activity , self .query .name == default_activity ["name" ])
2532 self .activities .update (activity , self .query .name == activity ["name" ])
2633
2734 def delete (self , activity ):
2835 activities .remove (self .query .name == activity ["name" ])
2936
30-
3137 def list (self ):
3238 return self .activities .all ()
3339
@@ -47,6 +53,64 @@ def init_default(self):
4753 "fontSize" : 'Medio' ,
4854 "showName" : True ,
4955 "maxBlocks" : None ,
56+ "capsSwitch" : True ,
57+ "bodyFont" : "Roboto" ,
58+ "availableViews" : [],
59+ "viewSource" : None ,
60+ "autoRecVideo" : None ,
61+ "toolbox" : {
62+ "kind" : "flyoutToolbox" ,
63+ "contents" : []
64+ },
65+ "buttons" : [
66+ {
67+ "action" : "clearProgramDlg" ,
68+ "icon" : "clear" ,
69+ "label" : "message.activity_program_clear" ,
70+ "type" : "text" ,
71+ },
72+ {
73+ "action" : 'saveProgram' ,
74+ "icon" : 'save' ,
75+ "label" : 'message.activity_program_save' ,
76+ "type" : 'text' ,
77+ },
78+ {
79+ "action" : 'toggleSaveAs' ,
80+ "icon" : 'edit' ,
81+ "label" : 'message.activity_program_save_as' ,
82+ "type" : 'text' ,
83+ },
84+ {
85+ "action" : 'loadProgramList' ,
86+ "icon" : 'folder_open' ,
87+ "label" : 'message.activity_program_load' ,
88+ "type" : 'text' ,
89+ },
90+ {
91+ "action" : 'runProgram' ,
92+ "icon" : 'play_arrow' ,
93+ "label" : 'message.activity_program_run' ,
94+ "type" : 'text' ,
95+ },
96+ {
97+ "action" : 'getProgramCode' ,
98+ "icon" : 'code' ,
99+ "label" : 'message.activity_program_show_code' ,
100+ "type" : 'text' ,
101+ },
102+ {
103+ "action" : 'exportProgram' ,
104+ "icon" : 'fa-file-export' ,
105+ "label" : 'message.activity_program_export' ,
106+ "type" : 'text' ,
107+ },
108+ {
109+ "action" : 'pickFile' ,
110+ "icon" : 'fa-file-import' ,
111+ "label" : 'message.activity_program_import' ,
112+ "type" : 'text' ,
113+ }],
50114 }
51115 self .save (activity )
52116
0 commit comments