@@ -15,19 +15,25 @@ def __init__(self):
15
15
self .activities = TinyDB ("data/activities.json" )
16
16
self .query = Query ()
17
17
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 ]
20
23
21
24
def save (self , activity ):
22
25
if self .activities .search (self .query .name == activity ["name" ]) == []:
23
26
self .activities .insert (activity )
24
27
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" ])
25
32
self .activities .update (activity , self .query .name == activity ["name" ])
26
33
27
34
def delete (self , activity ):
28
35
activities .remove (self .query .name == activity ["name" ])
29
36
30
-
31
37
def list (self ):
32
38
return self .activities .all ()
33
39
@@ -47,6 +53,64 @@ def init_default(self):
47
53
"fontSize" : 'Medio' ,
48
54
"showName" : True ,
49
55
"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
+ }],
50
114
}
51
115
self .save (activity )
52
116
0 commit comments