Skip to content

Commit

Permalink
chore(fix): Tour hangup error (#130)
Browse files Browse the repository at this point in the history
* fixed bug in tour not loading csv

* formatting
  • Loading branch information
tobiasmllr authored Apr 12, 2024
1 parent 23028d1 commit fc42321
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 48 deletions.
36 changes: 10 additions & 26 deletions frontend/rctool/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@ def rctool_import(request, tour_request_id=0):
context["tour_request_status_id"] = tour_request_id

if request.method == "POST":

print(request)
if request.POST.get("tour_request_status_id"):
context["tour_request_status_id"] = request.POST.get(
"tour_request_status_id"
)

# If user is on the tour, upload test data
if tour_request_id == 1:
context["form"] = import_rc_data()
return render(request, "rctool/rctool/import/rctool_import.html", context)

# if not on a tour, upload their dataset
import_form = import_rc_data(request.POST, request.FILES)
if import_form.is_valid():

Expand Down Expand Up @@ -162,21 +156,22 @@ def autofit_data(
)
]

rc_data_output = [
{"label": "field", "data": field_data}
] # if n_seg = 0, this will be the output
rc_data_output = [{"label": "field", "data": field_data}]

# if n_seg = 0, this will be the output
rc_param_output = None # if n_seg = 0, this will be the output
best_rc_data = None

# remove if row already exists
df_field = df_field.drop_duplicates(subset=["stage", "discharge"], keep="first")

# calculate the boundaries of each fit
x_min = df_field["stage"].min()
x_max = df_field["stage"].max()
x_step = (x_max - x_min) / 50
min_fitting_points = math.ceil(
len(df_field["stage"]) * 0.15
) # add constraint so fitting line has to pass through at least 20% of points
min_fitting_points = math.ceil(len(df_field["stage"]) * 0.15)

# add constraint so fitting line has to pass through at least 20% of points
rmse_best = 10000.00 # initialize with something unrealistically high

if n_seg == 1:
Expand Down Expand Up @@ -501,12 +496,9 @@ def rctool_develop_initialize(request):
context["toggle_breakpoint"] = "false"
context["toggle_weighted_fit"] = "false"
context["filename"] = df["filename"][0]
# get constraints fo input settings

# get constraints of input settings
context["max_offset"] = fielddatacsv_df["stage"].min()
# if parameter_rc_lst[0]['seg_bounds'][0][0] < fielddatacsv_df['stage'].min():
# context['max_offset'] = parameter_rc_lst[0]['seg_bounds'][0][0]
# else:
# context['max_offset'] = fielddatacsv_df['stage'].min()

df_filtered = fielddatacsv_df.drop_duplicates(
subset=["stage"], keep="first"
Expand Down Expand Up @@ -588,10 +580,6 @@ def rctool_develop_initialize(request):

# max offset
context["max_offset"] = field_df_raw["stage"].min()
# if context['rc']['parameters'][0]['seg_bounds'][0][0] < field_df_raw['stage'].min():
# context['max_offset'] = context['rc']['parameters'][0]['seg_bounds'][0][0]
# else:
# context['max_offset'] = field_df_raw['stage'].min()

except Exception as e:
print("Error in rctool_develop_initialize: " + repr(e))
Expand Down Expand Up @@ -1161,10 +1149,6 @@ def rctool_export_output(request):

return response

# except Exception as e:
# print("Error in rctool_export_output: " + repr(e))
# messages.error(request, "Unable to process request. " + repr(e))

context["form"] = export_form
context["rc_output"] = rc_output

Expand Down
22 changes: 0 additions & 22 deletions frontend/rctool_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY", "")

Expand Down Expand Up @@ -70,21 +67,13 @@

WSGI_APPLICATION = "rctool_project.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
Expand All @@ -100,10 +89,6 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"
Expand All @@ -112,17 +97,10 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = "static/"
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

0 comments on commit fc42321

Please sign in to comment.