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
Feature/event upload image #294
Feature/event upload image #294
Conversation
* feat: add i18n support This feature includes the core functions added to /internal, English and Hebrew json files, removal of text strings from the html files, updates to the routes and model updates. Also included are tests. Please note, that this feature is waiting on user registration for final hooks. By: Gonny <1@1>
* update ORM and added export for an event * update ORM and added export for an event * Added in app shareable events * docs: add type annotation and fix folder structure * docs: add type annotation and fix folder structure * docs: fix documentation * feat: get weather forecast for date and location * feat: get weather forecast for date and location * add: tests * set up commit * add: timezone support * add: session management * fix bug * split conftest file * split conftest file * move "utils" folder into "internal" folder * working day view with jinja2 template * with tests for pytest * feat: get weather forecast - fixes according to requested changes. * change file structure * feat: get weather forecast - fixes according to requested changes. * first functioning day-view html, css and router * feat: Basic responsive calender day view page Added dayview template with css and router. An tempreroy event class with, processing function for the day view to work. * feat: Basic responsive calender day view page Added dayview template with css and router. An tempreroy event class with, processing function for the day view to work. fixed after taking notes. * fix lint now for sure * more lint * feat: get weather forecast - fix requirements.txt * feat: enable invited users to view events * feat: flake8 changes * fix: requirements bug * fix: requirements bug * feat: flake8 changes * add: tests * feat: flake8 changes * add: tests * feat: flake8 changes * edit: file structure * edit: file structure * feat: get weather forecast - fix changes & add cache support * feat: get weather forecast - fix changes & add cache support * feat: get weather forecast - fix changes & add cache support * feat: add route tests * feat: get weather forecast - fix changes & add cache support * feat: get weather forecast - fix changes & add cache support * fix: test bug * remove: config.py * after all notes and started use the orm * fix: type annotation * feat: get weather forecast - add API mocking * feat: get weather forecast - add API mocking * feat: get weather forecast - add API mocking * feat: get weather forecast - add API mocking * fixed: changed "size" var in html and and more acuurate typing * deleted some testing lines * add requirements missing * add: minor changes * feat: flake8 changes * @hadaskedar2020 * feat: get weather forecast - add API mocking * feat: weather forecast - add API mocking & improve coverage * feat: weather forecast - add API mocking & improve coverage * feat: weather forecast - add API mocking & improve coverage * feat: weather forecast - add API mocking & improve coverage * feat: weather forecast - add API mocking & improve coverage * fixed: statements of event select more accurate * new test and lint fix * added more contants abd more notes taken * feat: weather forecast - move feat to internal * Delete Scripts directory * update constants * more notes * forgot white space * feat: gets a link to the suitable image of a given event content. (PythonFreeCourse#70) * feat: gets a link to the suitable image of a given event content. * Add basic update event (PythonFreeCourse#100) * Add basic update event * Added search feature (PythonFreeCourse#98) * Added search feature * Add telegram client (PythonFreeCourse#111) Add telegram client * feat: Add a feature for sharing information with a WhatsApp account (PythonFreeCourse#83) * feat: Add a feature to share to a WhatsApp account * Feature/logging system (PythonFreeCourse#112) * feat: first logging commit Co-authored-by: Liad Noam <LiadN@Taldor.corp> * feat: add a daily inspirational quote (PythonFreeCourse#128) * feat: add a daily inspirational quote * Feature/delete event (PythonFreeCourse#139) * basic delete event * Add an event delete function * Fix flake8 * Deleting an unnecessary model * Extract lines from try * fix: modify psycopg2 dependency (PythonFreeCourse#164) * Bugfix/logging system (PythonFreeCourse#158) * Changed logging config to be received by separate parameters for simplicity, removed option to receive configuration as a dict, added .vscode to gitignore * removed logging_config file which is no longer needed * Fixing merge conflicts - missing whitespace on config.py.example Co-authored-by: Liad Noam <LiadN@Taldor.corp> * Added checking for zoom link and saving the event (PythonFreeCourse#122) * Added checking for zoom link and saving the event * Feature/import to calendar (PythonFreeCourse#119) * feat: import file to calendar * docs: adding community standard documents (PythonFreeCourse#173) * Feat: Event View Backend (PythonFreeCourse#159) * Moved the route to top of file * Feature/send email (PythonFreeCourse#88) * Added files for sending invitations by email This includes - templates - routes and internal code - configuration - tests Co-authored-by: leddest <46251307+leddest@users.noreply.github.com> Co-authored-by: Ellen <ellenc345@gmail.com> * Feature/translation - add an functionality to translate event data etc. (PythonFreeCourse#167) * translation feature stuff * Update event - Improving the code (PythonFreeCourse#138) * Add basic update event * Support categories for events (PythonFreeCourse#137) * Support categories for events * Style/grid (PythonFreeCourse#106) * Hello Wrold * Creating Html Template * Calendar dates calculation intigrating with html, HTML\CSS improvments. * Tests for calender_grid.py, changing function according to currections, fixing bugs * linting bug fixing * before merge with develop * Creating a Day object and days subclasses, changing all function and tests according to the new objects, Changing front to get information from Day objects, Re-arranging calendar.html grid stracture to be render by weeks, adding js functionality for day view section, adding css effects on daily event display * fix lintings * fix lintings * tests next week scroll * js updates * Calendar Scrolling with javascript * Fix lintings * Fix lintings * Calendar infinit scrolling ducplicates weeks bug fixed * seetings global parameters for calendar.py * Js - changing to fetch, removing jquery, fixing hint tpying, adding Week object, changing tests * Front end bug fixing * Fix linting * Fix lintings * Fix lintings * fixing syntax * Get user local date and time when enter calendar. * Fix lintings * Fix lintings * Fix lintings * Bugs fixing * Bugs fixing * Bugs fixing * Bugs fixing * JS alerts removal * Fix Lintings * Js syntext fixing * Bugs fixing * Bugs fixing * Js fixing varibales and adding div element to request. * Develop Update * Js - eliminate global parameters * Linting fixing * Fix Lintings * Fix flake8 * syntac fixing * Feature/translations workflow (PythonFreeCourse#150) * feat: add translations workflow * fix(translations-workflow): fix doc * fix(translations-workflow): fixed code and added automatic commit Co-authored-by: Gonny <1@1> * Revert "Feature/translations workflow (PythonFreeCourse#150)" (PythonFreeCourse#208) This reverts commit 2e6a2c2. * feat: Add zodiac signs to the day & month view + refactor json data loader (PythonFreeCourse#155) * feat: Add zodiac signs to the day/month view + * Change calendar link from '#' to '/' to get the home page (PythonFreeCourse#194) when clicking on the logo * Style/grid (PythonFreeCourse#200) * Js scrolling duplication days fixed Co-authored-by: Idan Pelled <pelled.idan@gmail.com> Co-authored-by: Hadas Kedar <hadasit@gmail.com> Co-authored-by: Sagi Zaid Or <sagi@eretz.org.il> Co-authored-by: sagizaidor <71097154+sagizaidor@users.noreply.github.com> Co-authored-by: hadaskedar2020 <70915466+hadaskedar2020@users.noreply.github.com> Co-authored-by: nir9696 <35953934+nir9696@users.noreply.github.com> Co-authored-by: efratush <70986341+efratush@users.noreply.github.com> Co-authored-by: advaa123 <64307569+advaa123@users.noreply.github.com> Co-authored-by: leddest <46251307+leddest@users.noreply.github.com> Co-authored-by: nelliei <71073199+nelliei@users.noreply.github.com> Co-authored-by: Liad-n <52039539+Liad-n@users.noreply.github.com> Co-authored-by: Liad Noam <LiadN@Taldor.corp> Co-authored-by: zohary89 <71074080+zohary89@users.noreply.github.com> Co-authored-by: Ron Huberfeld <32178925+ron-huberfeld@users.noreply.github.com> Co-authored-by: Ap1234567 <58956386+Ap1234567@users.noreply.github.com> Co-authored-by: Nir-P <70997974+Nir-P@users.noreply.github.com> Co-authored-by: Ode <odechann@gmail.com> Co-authored-by: Anna Shtirberg <71028276+annashtirberg@users.noreply.github.com> Co-authored-by: Ellen <ellenc345@gmail.com> Co-authored-by: ivarshav <ivarshav@users.noreply.github.com> Co-authored-by: Aviad <38867584+aviadamar@users.noreply.github.com> Co-authored-by: Gonzom <gonnym@gmail.com> Co-authored-by: Gonny <1@1> Co-authored-by: YairEn <71101056+YairEn@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## develop #294 +/- ##
===========================================
- Coverage 95.41% 95.33% -0.08%
===========================================
Files 79 79
Lines 3575 3603 +28
===========================================
+ Hits 3411 3435 +24
- Misses 164 168 +4
Continue to review full report at Codecov.
|
app/database/models.py
Outdated
Integer, CheckConstraint("0<=off_day<=6"), nullable=False, | ||
Integer, | ||
CheckConstraint('0<=off_day<=6'), | ||
nullable=False, | ||
default=SalaryConfig.SATURDAY, | ||
) | ||
# holiday_category_id = Column( |
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.
can remove?
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 not part of my feature actually. This is in the develop. The changes are only because of the new autoformatter Yam put in the prehooks
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.
Though I don't mind removing it but I don't know who has been using this :)
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.
Awesome start!
Co-authored-by: kobyfogel <71118404+kobyfogel@users.noreply.github.com>
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.
Great start! I've added few insights :)
@@ -99,6 +99,7 @@ class Event(Base): | |||
invitees = Column(String) | |||
privacy = Column(String, default=PrivacyKinds.Public.name, nullable=False) | |||
emotion = Column(String, nullable=True) | |||
image = Column(String, nullable=True) |
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 think it's actually a String, unless you converted it to some textual format as base64. In any other case, it's probably Binary or something like that
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.
it's str as it is just the file name (similar to what was done on upload profile image)
app/routers/event.py
Outdated
image_data = list(resized.getdata()) | ||
image_without_exif = Image.new(resized.mode, resized.size) | ||
image_without_exif.putdata(image_data) | ||
image_without_exif.save(f"{MEDIA_PATH}/{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.
For security reasons, there should be an UPLOAD_PATH
that is separate from the MEDIA_PATH
.
You can set it in the configuration file.
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.
Where should I put the upload path? should it be a sub directory of media or an entirely new directory?
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 want to be delayed (my 3rd PR woohoo!) so I created a directory under "app" as I saw several folders were created like this.
Easy to change if you just say the word
…uni/calendar into feature/event_upload_image
…uni/calendar into feature/event_upload_image
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.
Great job, almost there :)
app/dependencies.py
Outdated
@@ -11,19 +11,22 @@ | |||
GOOGLE_ERROR = config.CLIENT_SECRET_FILE is None | |||
APP_PATH = os.path.dirname(os.path.realpath(__file__)) | |||
MEDIA_PATH = os.path.join(APP_PATH, config.MEDIA_DIRECTORY) | |||
EVENT_IMAGES_PATH = os.path.join(APP_PATH, config.EVENT_IMAGE_DIRECTORY) |
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.
Prefer having EVENT_IMAGE_DIRECTORY
as an absolute location.
If the user want to create a safe environment, he or she might choose to store the images in a location that has nothing to do with the directory of the application itself.
Also, prefer calling it UPLOAD_PATH
.
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.
changed to UPLOAD_PATH.
I added a comment about specifiying a specific local path in the config. However for testing purposes I mentioned that they can specify a folder name and that will be created under app/ (I check whether they put a valid path and otherwise try to create a dir under the working directory).
I think this is easier at least for testing purposes but let me know what you think.
app/routers/event.py
Outdated
image_data = list(resized.getdata()) | ||
image_without_exif = Image.new(resized.mode, resized.size) | ||
image_without_exif.putdata(image_data) | ||
image_without_exif.save(f"{EVENT_IMAGES_PATH}/{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.
I think it might be useful to randomize the name to prevent people overriding other people images (if some event have two wedding_invite.png
, we should allow 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.
The name is actually the event's id , not the name of the uploaded picture. Therefore there will be only one picture associated to the event, and it is easier to associate it with the event.
app/config.py.example
Outdated
"""For security reasons, set the upload path to a local absolute path. | ||
Or for testing environment - just specify a folder name | ||
that will be created under /app/""" | ||
UPLOAD_DIRECTORY = 'event_images' |
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.
@yammesicka this is the comment in the config example to explain to users it's preferable to use a local directory.
app/config.py.example
Outdated
"""For security reasons, set the upload path to a local absolute path. | ||
Or for testing environment - just specify a folder name | ||
that will be created under /app/""" |
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.
Prefer # before each line - docstring are reserved for general documentation
add the option to upload an image to be attached to the event and view it on the eventview page