Skip to content

Commit

Permalink
Merge pull request #118 from upsonp/3.1.10
Browse files Browse the repository at this point in the history
Added cancel button for 'new' mission dir field #114
  • Loading branch information
upsonp authored Mar 26, 2024
2 parents 6d85d86 + a45cff9 commit e44232d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
50 changes: 33 additions & 17 deletions settingsdb/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,22 @@ def add_mission_dir(request):
submit.attrs['hx-target'] = '#div_id_directory'
submit.attrs['hx-select'] = '#div_id_directory'
submit.attrs['hx-swap'] = 'outerHTML'
submit.attrs['title'] = _('Add directory')
submit.append(BeautifulSoup(load_svg('plus-square'), 'html.parser').svg)

cancel = soup.new_tag('button')
cancel.attrs['class'] = 'btn btn-danger btn-sm ms-2 col-auto'
cancel.attrs['name'] = "cancel"
cancel.attrs['hx-post'] = request.path
cancel.attrs['hx-target'] = '#div_id_directory'
cancel.attrs['hx-select'] = '#div_id_directory'
cancel.attrs['hx-swap'] = 'outerHTML'
cancel.attrs['title'] = _('Cancel')
cancel.append(BeautifulSoup(load_svg('x-square'), 'html.parser').svg)

row.append(station_input)
row.append(submit)
row.append(cancel)

soup.append(row)

Expand All @@ -304,29 +316,33 @@ def add_mission_dir(request):
select_soup = BeautifulSoup(mission_html)
soup.append(select_soup.find(id="select_id_mission_directory"))

response = HttpResponse(soup)
response['Hx-Trigger'] = "db_dir_changed"
return response

elif 'directory' in request.POST:
new_location = request.POST['directory']
if new_location.strip() == '':
location = setting_models.LocalSetting.objects.first()
elif not (location := setting_models.LocalSetting.objects.filter(database_location=new_location)).exists():
location = setting_models.LocalSetting(database_location=new_location)
location.save(using='default')
location = setting_models.LocalSetting.objects.order_by('id').last()
else:
location = location.first()
else:
location = setting_models.LocalSetting.objects.first()
if 'cancel' in request.POST:
if setting_models.LocalSetting.objects.filter(connected=True).exists():
location = setting_models.LocalSetting.objects.get(connected=True)

elif 'directory' in request.POST:
new_location = request.POST['directory']
if new_location.strip() == '':
location = setting_models.LocalSetting.objects.first()
elif not (location := setting_models.LocalSetting.objects.filter(database_location=new_location)).exists():
location = setting_models.LocalSetting(database_location=new_location)
location.save(using='default')
location = setting_models.LocalSetting.objects.order_by('id').last()
else:
location = location.first()

reset_connection(location.pk)

mission_form = MissionDirForm(initial={"directory": location.pk})
mission_html = render_crispy_form(mission_form)

response = HttpResponse(mission_html)
response['Hx-Trigger'] = "db_dir_changed"
return response
soup = BeautifulSoup(mission_html, 'html.parser')

response = HttpResponse(soup)
response['Hx-Trigger'] = "db_dir_changed"
return response


def migrate_database(request, database):
Expand Down
2 changes: 1 addition & 1 deletion start_dart.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if not exist ".\logs\" (
mkdir logs
)

set dart_version=3.1.9
set dart_version=3.1.10

REM if this is not a git repo, and the application was installed from zip file we just want to run update
REM if this is a cloned version of the git repo we want to pull from master, then run the update
Expand Down
2 changes: 1 addition & 1 deletion update.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if not exist ".\logs\" (
REM If this was run from a clone repo we can force an update of the python libraries, collectstatic or a
REM migration on the database by changing the update version

set update_version=3.1.9
set update_version=3.1.10

set first_run=0
set server_path=.\dart_env\Scripts\activate.bat
Expand Down

0 comments on commit e44232d

Please sign in to comment.