new feature: m number marks work as mastered for active player and shows movements

This commit is contained in:
2023-11-07 14:32:11 +01:00
parent 10894187b2
commit a75a241f30
2 changed files with 52 additions and 8 deletions

View File

@@ -11,16 +11,18 @@ At the moment, an alpha version is undertaken, with these features:
- The sqlite-database holds a growing number of piano-solo pieces, together with their exact catalogue-numbers and composers.
- Prepared in this database is a table for users (pianists), that marks which of the pieces can be played.
### Application
### Application and usage
- Create new users
- Set an active user
- Show the pieces stored in the database
- (planned) Mark pieces as masterd for the active user
- Create new users (`n username`)
- Show users (`su`)
- Set an active user (`a number_of_user`)
- Show the pieces stored in the database (`s`)
- Mark pieces as mastered for the active user (`m number_of_work`)
- (planned) Show pieces by composer
- (planned) Show movements throug pieces
- (planned) Show movements through pieces
## Requirements
- Python 3.9 or higher
- Enough disk space to hold the database
- Enough disk space to hold the database
- run `python builddb.py` to build the SQLite-database-file before running `python rep_cli.py`

View File

@@ -29,6 +29,8 @@ class Session:
self.resultstring = ''
if command == 'a':
self.resultstring += self.set_user(arguments[0])
elif command == 'm':
self.resultstring += self.mark_work_as_mastered(arguments[0])
elif command == 'n':
self.create_new_user(arguments[0], arguments[1])
self.resultstring += f'Created new user {arguments[0]} {arguments[1]}.'
@@ -76,6 +78,17 @@ class Session:
fun_resultstring += f'{work.id()}: {work.pretty_string()}\n'
return fun_resultstring
def mark_work_as_mastered(self, work_id):
resultstring = 'adding:\n'
work = work_under_id(work_id, self.db_agent)
for mov_number in work.values['movements'].keys():
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
# End session
@@ -149,6 +162,35 @@ class work_under_id:
ret_str += f'{self.values[key]} '
return ret_str
def pretty_mov(self, mov_number):
ret_str = ''
for key in ['first_name', 'name',
'title', 'mov_title', 'opus', 'numb',
'main_key', 'alias',
'movements',
'work_directory','wd_number']:
if key in self.values.keys() and not self.values[key] is None:
if key == 'opus':
ret_str += f'op. {self.values[key]} '
elif key == 'name':
ret_str += f'{self.values[key]}, '
elif key == 'numb':
ret_str += f'Nr. {self.values[key]} '
elif key == 'movements':
if self.values[key][mov_number][1] is None:
ret_str += ''
else:
if len(self.values[key]) > 1:
ret_str += f'{mov_number}. {self.values[key][mov_number][1]} '
else:
ret_str += f'{self.values[key][mov_number][1]} '
elif key == 'title':
if self.values['mov_title'] is None:
ret_str += f'{self.values[key]} '
else:
ret_str += f'{self.values[key]} '
return ret_str
def __str__(self):
ret_str = ''
for key, value in self.values.items():
@@ -161,7 +203,7 @@ class work_under_id:
def parse_user_input(user_in):
split_user_in = user_in.split()
command = split_user_in[0]
if command in ('a', 'n', 'q', 's', 'su'):
if command in ('a', 'm', 'n', 'q', 's', 'su'):
arguments = split_user_in[1:]
return (command, arguments)
else: