Skip to content

Commit

Permalink
feat: added changes as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
rb-25 committed Mar 24, 2024
1 parent 2b925b8 commit c179a9b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 0 additions & 3 deletions student_welfare_backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,3 @@ student_welfare_backend/media/
# Credentials
credentials/*
!credentials/.gitkeep

#Temp
student_council.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ def process_csv_func(self, row_data, responses):
# Validate required fields
missing_fields = [field for field in self.REQUIRED_FIELDS if row_data[field] is None]
if missing_fields:
raise ValueError(f"Missing required fields: {', '.join(missing_fields)}")
raise ValueError(f"Missing required fields: {', '.join(missing_fields)}")

# Check if the month is valid accoring to role choices
if row_data["month"].lower() not in dict(Newsletter.month_names).keys():
invalid_month = row_data["month"].lower()
raise ValueError(f"Invalid type: {invalid_month}")

month1 = row_data["month"].lower()

# Check if the type is valid
if month1 not in dict(Newsletter.month_names).keys():
raise ValueError(f"Invalid type: {month1}")
# Create special file
newsletter = Newsletter.objects.update_or_create(
year=row_data["year"],
month=month1,
month=row_data["month"].lower(),
cover_page=row_data["cover_page"],
link=row_data["link"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UsersCSVImporter:
def process_csv_func(self, row_data, responses):
try:
# Validate required fields
missing_fields = [field for field in self.required_columns if row_data[field] is None]
missing_fields = [field for field in self.REQUIRED_FIELDS if row_data[field] is None]
if missing_fields:
raise ValueError(f"Missing required fields: {', '.join(missing_fields)}")

Expand Down

0 comments on commit c179a9b

Please sign in to comment.