Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Program Management section of Admin Settings #1281

Open
wants to merge 85 commits into
base: development
Choose a base branch
from

Conversation

Kafui123
Copy link
Contributor

@Kafui123 Kafui123 commented Jul 16, 2024

Issue

Issue: #797

Changes

  • Created a modal to update the information displayed for the programs on the homepage.
  • Fields include program name, description, partner, contact email, contact name, and location.
  • Implemented a add a new file feature, to change the image of the programs on the homepage.
  • Saved changes button works as expected, and there are two ways to close the modal, cancel or cross button.
  • Partner, contact email, contact name, location all stored in database.
  • Program name, description, images and links can be directly seen in the home screen.
  • Added editable link for Instagram, Facebook and Berea URL.
  • Refactored testing function

Testing

  • Checkout refactorProgramMgmt
  • ./database/reset_database.sh test
  • flask run
  • Go to Admin -> Settings
  • Open up the Program Settings accordion
  • Click on 3-4 programs and upload a png to 2 and a jpg to 2.
  • Go to the landing page and make sure the landing page images for each program reflects what you uploaded.
  • Go to app/static/files/programattachments and make sure that there is only one file for each program (1.jpg, 2.png, etc.)
  • Once your testing has concluded delete all files that were just added and are not source controlled (pngs or any other different file types)
  • Run git restore .
  • If it does not properly add back all files that were initially there you may have to manually add them from GitHub or an earlier commit.

JohnCox2211 and others added 14 commits July 5, 2024 14:38
saving solution in route, currently get system
error.
some white space and useless comments and moved
some css to its proper location. Image solution
still doesn't work, will ask a higher power about
it on monday
file handler, was trying to use userManagement.py
except as a foreign key value in program to store
one charfield variable. Add some things to hopefully
handle files, not working. Updated the test data
to contain added data fields.
…rrently attempting to change the file name to the name of the program along with the file extension.
…dal and the msgToast is also in front of the modal and clearly visible.
app/logic/fileHandler.py Outdated Show resolved Hide resolved
@thealphagurlux
Copy link

When trying to upload a picture for a event, if you exit out of the modal and open it the file name will still be there and the same file will still be uploaded if saved.

I suggest clearing the picture and file name when the user exits the modal.

image

@thealphagurlux
Copy link

For the following programs, when trying to change the event picture in settings the picture doesn't change:

-Berea Teen Mentoring
-Hispanic Outreach Program
-People Who Care

@bledsoef
Copy link
Contributor

For the following programs, when trying to change the event picture in settings the picture doesn't change:

-Berea Teen Mentoring -Hispanic Outreach Program -People Who Care

@thealphagurlux I double checked these on my machine and Anna's and we could not replicate the issue you found.

@thealphagurlux
Copy link

For the following programs, when trying to change the event picture in settings the picture doesn't change:
-Berea Teen Mentoring -Hispanic Outreach Program -People Who Care

@thealphagurlux I double checked these on my machine and Anna's and we could not replicate the issue you found.

@thealphagurlux
Copy link

For the following programs, when trying to change the event picture in settings the picture doesn't change:
-Berea Teen Mentoring -Hispanic Outreach Program -People Who Care

@thealphagurlux I double checked these on my machine and Anna's and we could not replicate the issue you found.

I had not reset my database or restored the git branch while looking for bugs. This is what was causing the issue.

@BrianRamsay BrianRamsay reopened this Nov 19, 2024
Copy link

View Code Coverage

filePaths = FileHandler(programId=programID).retrievePath(associatedAttachments)


file_paths = {filename: path_info[0] for filename, path_info in filePaths.items()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "filePaths" variable and the "file_paths" variable should be both camelcase. The also should have different variable names.

fileType = file.filename.split('.')[-1]
fileName = f"{self.programId}.{fileType}"
AttachmentUpload.create(program=self.programId, fileName=fileName)
current_programID = fileName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be camelCase

flash("Program updated", "success")
return redirect(url_for("admin.userManagement", accordion="program"))
except Exception as e:
print(e)
flash('Error while updating program info.','warning')
print("error: ", e)
Copy link
Contributor

@Mbeweg Mbeweg Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of the ``"print("error: ", e)" `we don't need it.

if (single){
$(objectContainerId).html(fileHTML)
}
else{
msgToast("File with filename '" + file.name + "' has already been added to this event")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

AttachmentUpload.create(program=self.programId, fileName=fileName)
current_programID = fileName
saveFileToFilesystem = current_programID

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using snake_case for variable naming is better.
deleteFileObject to delete_file_object.
fileType to file_type.
fileName to file_name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.