Skip to content

Conversation

imimouni
Copy link
Contributor

@imimouni imimouni commented Feb 9, 2021

Add privacy setting to the user's calendar.

@@ -42,6 +42,7 @@ class User(Base):
avatar = Column(String, default="profile.png")
telegram_id = Column(String, unique=True)
is_active = Column(Boolean, default=False)
privacy = Column(String, default="Private", nullable=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

If the only values you expect are "private" and "public", consider using boolean type - True ( for private) and Falsr (for public).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally the feature was planned to contain "friends" as a level of privacy.
This feature has yet to be approved or implemented but I think a room for this option and other levels of privacy can be allowed

Copy link
Contributor

Choose a reason for hiding this comment

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

So maybe use Enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As this is not a free text field but rather something from a set of closed options in a dropdown I don't think there is any reason to fear an incorrect value here
Also I am not sure whether in the setting here the solution would be Enum rather than another connecting table like they did in language. In any case I dont think that it is relevant in the situation here right now

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 that it's a good practice to add a validation also in backend and in db.
Also, I think that you can get better performance with this option (but I guess we are not worried about that..).

I agree that right now it's too much to add another table.

Please make sure that it's invalid to add a bad value, even if someone tries :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where would you suggest doing this? I didn't see that anyone did something similar I think... It can't be in the models file obviously.. and as I mentioned no one can enter values I did not specify in the drropdown field, it's not a free text where anyone can enter what they want, just a set of options. Does that not qualify as verifying that only possible values can be entered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so anything? or can I resolve this? :)

@codecov-io
Copy link

codecov-io commented Feb 9, 2021

Codecov Report

Merging #247 (b563b02) into develop (856c843) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #247      +/-   ##
===========================================
- Coverage    99.06%   99.05%   -0.02%     
===========================================
  Files           48       53       +5     
  Lines         2251     2431     +180     
===========================================
+ Hits          2230     2408     +178     
- Misses          21       23       +2     
Impacted Files Coverage Δ
app/database/models.py 96.31% <100.00%> (-0.31%) ⬇️
app/internal/calendar_privacy.py 100.00% <100.00%> (ø)
app/routers/profile.py 92.72% <100.00%> (+0.64%) ⬆️
app/internal/utils.py 100.00% <0.00%> (ø)
app/routers/export.py 100.00% <0.00%> (ø)
app/routers/dayview.py 100.00% <0.00%> (ø)
app/internal/agenda_events.py 100.00% <0.00%> (ø)
app/routers/weekview.py 100.00% <0.00%> (ø)
app/routers/four_o_four.py 85.71% <0.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 856c843...b563b02. Read the comment docs.

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Awesome work! I've added few of my insights, please take a look.

@imimouni imimouni requested a review from yammesicka February 10, 2021 19:59
Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Almost ready for merge :)

@@ -54,7 +60,7 @@
<div class="modal-dialog profile-modal-dialog profile-modal-fadeIn">
<div class="modal-content">
<div class="modal-header profile-modal-header">
<h5 class="modal-title">{{ gettext("Update name") }}</h5>
<h1 class="modal-title">{{ gettext("Update name") }}</h1>
Copy link
Member

Choose a reason for hiding this comment

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

There should be only single h1 in each page. You can lots of h2s under a single h1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well there is no h1 in the entire profile page but I changed them all to h2 if that's alright. They are all in the same level

data = await request.form()
new_privacy = data['privacy']

# Update database
Copy link
Contributor

Choose a reason for hiding this comment

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

you can delete the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment appears in all the other forms so I just kept the same structure :) Unless a decision is made to remove the comments from all the file I think this should stay

db=session, current_user=current_user
)
assert result_a is False
assert result_b is True
Copy link
Contributor

Choose a reason for hiding this comment

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

you can write it down as
assert result_b

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got a previous comment saying to do the opposite haha ... let's just stay with this:)

@yammesicka yammesicka merged commit 33788a1 into PythonFreeCourse:develop Feb 15, 2021
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.

5 participants