Compare commits
2 Commits
c6057ff8f7
...
8db8deee79
| Author | SHA1 | Date | |
|---|---|---|---|
| 8db8deee79 | |||
| fb13941756 |
@@ -27,7 +27,8 @@ At the moment, an alpha version is undertaken, with these features:
|
|||||||
- Works are shown sorted by composer and opus/work_directory-number (`s`, `smo`) or by composer and collection (`sm`)
|
- Works are shown sorted by composer and opus/work_directory-number (`s`, `smo`) or by composer and collection (`sm`)
|
||||||
- Remove work or movement from being mastered for active user (`r number_of_work` or `r number_of_work number_of_movement`)
|
- Remove work or movement from being mastered for active user (`r number_of_work` or `r number_of_work number_of_movement`)
|
||||||
- Remove user (`delete_my_user_record_including_all_mastered_works`)
|
- Remove user (`delete_my_user_record_including_all_mastered_works`)
|
||||||
- (planned) Fix known bugs
|
- Fixed bug: double marking crashes the program
|
||||||
|
- Fixed bug: check for user before setting
|
||||||
|
|
||||||
_(planned) Release piano_repertoire_cli V 0.0.1 alpha (learn about versioning before)_
|
_(planned) Release piano_repertoire_cli V 0.0.1 alpha (learn about versioning before)_
|
||||||
|
|
||||||
@@ -44,4 +45,5 @@ _(planned) Port funtionality to a kivy-GUI_
|
|||||||
|
|
||||||
## Known Bugs
|
## Known Bugs
|
||||||
|
|
||||||
- Marking a piece as mastered the second time, the database won’t insert the entry and the program will crash
|
- Trying to mark works as mastered that are not present crashes the program
|
||||||
|
- Providing alphabetic chars where numbers are expected crashes the program
|
||||||
36
rep_cli.py
36
rep_cli.py
@@ -23,9 +23,19 @@ class Session:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def set_user(self, arguments):
|
def set_user(self, arguments):
|
||||||
|
resultstring = ''
|
||||||
db_index = arguments[0]
|
db_index = arguments[0]
|
||||||
self.user = db_index
|
sql_command = f'''
|
||||||
return 'User set'
|
SELECT *
|
||||||
|
FROM pianist
|
||||||
|
WHERE id = {db_index}
|
||||||
|
'''
|
||||||
|
if self.db_agent.execute(sql_command).fetchone():
|
||||||
|
self.user = db_index
|
||||||
|
resultstring += 'User set'
|
||||||
|
else:
|
||||||
|
resultstring += 'No such user'
|
||||||
|
return resultstring
|
||||||
|
|
||||||
def get_active_user(self):
|
def get_active_user(self):
|
||||||
sql_command = f'''
|
sql_command = f'''
|
||||||
@@ -218,20 +228,26 @@ class Session:
|
|||||||
work = work_under_id(work_id, self.db_agent)
|
work = work_under_id(work_id, self.db_agent)
|
||||||
if len(arguments) > 1: # in case there is a movement number given
|
if len(arguments) > 1: # in case there is a movement number given
|
||||||
mov_number = int(arguments[1])
|
mov_number = int(arguments[1])
|
||||||
sql_command = f'''
|
if self.movement_is_mastered(work_id, mov_number):
|
||||||
INSERT INTO is_able_to_play (work_id, mov_id, pianist_id)
|
resultstring += f'Already marked as mastered: {work.pretty_mov(mov_number)}\n'
|
||||||
VALUES ({work_id}, {mov_number}, {self.user})
|
else:
|
||||||
'''
|
|
||||||
self.db_agent.execute(sql_command)
|
|
||||||
resultstring += f'{work.pretty_mov(mov_number)}\n'
|
|
||||||
else: # mark all movements of the work as mastered
|
|
||||||
for mov_number in work.values['movements'].keys():
|
|
||||||
sql_command = f'''
|
sql_command = f'''
|
||||||
INSERT INTO is_able_to_play (work_id, mov_id, pianist_id)
|
INSERT INTO is_able_to_play (work_id, mov_id, pianist_id)
|
||||||
VALUES ({work_id}, {mov_number}, {self.user})
|
VALUES ({work_id}, {mov_number}, {self.user})
|
||||||
'''
|
'''
|
||||||
self.db_agent.execute(sql_command)
|
self.db_agent.execute(sql_command)
|
||||||
resultstring += f'{work.pretty_mov(mov_number)}\n'
|
resultstring += f'{work.pretty_mov(mov_number)}\n'
|
||||||
|
else: # mark all movements of the work as mastered
|
||||||
|
for mov_number in work.values['movements'].keys():
|
||||||
|
if self.movement_is_mastered(work_id, mov_number):
|
||||||
|
resultstring += f'Already marked as mastered: {work.pretty_mov(mov_number)}\n'
|
||||||
|
else:
|
||||||
|
sql_command = f'''
|
||||||
|
INSERT INTO is_able_to_play (work_id, mov_id, pianist_id)
|
||||||
|
VALUES ({work_id}, {mov_number}, {self.user})
|
||||||
|
'''
|
||||||
|
self.db_agent.execute(sql_command)
|
||||||
|
resultstring += f'{work.pretty_mov(mov_number)}\n'
|
||||||
return resultstring
|
return resultstring
|
||||||
|
|
||||||
def remove_work_as_mastered(self, arguments):
|
def remove_work_as_mastered(self, arguments):
|
||||||
|
|||||||
Reference in New Issue
Block a user