-
Notifications
You must be signed in to change notification settings - Fork 0
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
Main site publish functionality #40
base: master
Are you sure you want to change the base?
Conversation
a better location
Currently beautiful soup is used to get headlines from articles
…f/kerckhoff-server into cliu/wordpress-integrations-tests
Before, the type hint for content was dict, even though it should actually be list
Currently only has tests that do not require kerckhoff packages, google drive, or Wordpress POST requests. These other tests will be added later
The return data provides data allowing posts to be deleted in tests
String concatenation creates too much unnecessary copying
- Add logger for kerckhoff module - Replace print statements with log statements - Remove unnecessary print statements
This reverts commit 4d59e92. Cover images should not be optional
- Log level - Don't capture unit test stdout - Add coverage reports to gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to submit this review a long time ago
@@ -0,0 +1,168 @@ | |||
import tempfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file still used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's the python tempfile package used in image uploading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's not used in models.py anymore so I'll remove it
MYSQL_DATABASE: wordpress | ||
MYSQL_USER: wordpress | ||
MYSQL_PASSWORD: wordpress | ||
wordpress: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use the wordpress docker container and/or do you think it would be ok to use the docker container instead of the fake mainsite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use the wordpress docker container. We added this a long time ago so I don't quite remember what exactly we were planning. I think I should be able to remove it
@@ -0,0 +1,159 @@ | |||
import tempfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file might have been created accidently
kerckhoff/packages/exceptions.py
Outdated
@@ -6,3 +6,9 @@ class GoogleDriveNotConfiguredException(APIException): | |||
|
|||
def __init__(self, package): | |||
self.detail = f"Google Drive is not yet configured for {package.slug}." | |||
|
|||
class PublishError(APIException): | |||
status_code = 400 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I feel like it might be more of a 500 error since the server was unable to fulfill a valid request (400 means request was bad)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's hard to say, because some of them are due to invalid AML, and others are because the server failed to do something. I think I'll add an argument to specify the error code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh I see. Yeah in that case I think an argument would be good
kerckhoff/packages/models.py
Outdated
if(file.file_name == "data.aml"): | ||
json_data = file.data | ||
if("jpg" in file.file_name or "jpeg" in file.file_name | ||
or "png" in file.file_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be ok if we just checked if the file ended with jpg, jpeg or png? (there might be some built in python package that can do that for us). The reason is because this could possibly lead to us uploading files like "png_list.txt" to wordpress' media library and that might fail causing the whole publish operation to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll use the python os package for that. I don't remember if I only allow jpg, jpeg and png because DB only uses those file types, or if I simply forgot to include more. Do you know if kerckhoff should be able to support other image extensions as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing they would want to have in the future is gifs sometimes. However, there some changes we need to make to aws uploading code to support gifs so for now we can leave it out
The old file was probably getting it from models.py, and it broke after I removed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the merge conflict but besides that good to go!
for chunk in res.iter_content(chunk_size=1000): | ||
f.write(chunk) | ||
headers = self.basic_auth_header | ||
headers["Content-Disposition"] = f"form-data; filename={file_name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a small thing but technically modifying headers will modify self.basic_auth_header.
This pull request enables publishing to the Daily Bruin main site through WordPress REST API from Kerckhoff. Includes:
Change the .env file to specify the desired URL and credentials for publishing. Currently set to DB test site.