Skip to content

Commit

Permalink
try again
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Kehl committed Jan 16, 2025
1 parent e600087 commit 4519a5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 0 additions & 4 deletions app/main/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def __init__(self, message="Not a csv file"):
self.message = message

def __call__(self, form, field):
if not Spreadsheet.approves_headers(field.data):
raise ValidationError(
f"{field.data.filename} does not have headers in row 1"
)
if not Spreadsheet.can_handle(field.data.filename):
raise ValidationError(
"{} is not a spreadsheet that Notify can read".format(
Expand Down
9 changes: 5 additions & 4 deletions app/models/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def as_csv_data(self):
self._csv_data = converted.getvalue()
return self._csv_data

@classmethod
def approves_headers(cls, field_data):
raise Exception(f"Field data {field_data}")

@classmethod
def can_handle(cls, filename):
Expand All @@ -46,7 +43,11 @@ def get_extension(filename):

@staticmethod
def normalise_newlines(file_content):
return "\r\n".join(file_content.read().decode("utf-8").splitlines())
rows = file_content.read().decode("utf-8").splitlines()
if rows.get(0) is None or rows[0] == "":
raise Exception("No header row")
return "\r\n".join(rows)


@classmethod
def from_rows(cls, rows, filename=""):
Expand Down

0 comments on commit 4519a5a

Please sign in to comment.