Skip to content

Benefit Features db modeling #1813

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

Merged
merged 17 commits into from
Jul 22, 2021
Merged

Benefit Features db modeling #1813

merged 17 commits into from
Jul 22, 2021

Conversation

berinhard
Copy link
Contributor

@ewdurbin this is still a WIP, but I'm opening it so you can review how I implemented the DB modeling we've talked about recently. Besides that, this PR also enables PSF staff from adding features to an existing benefit vai Django's stack inline admin.

The process is pretty much intuitive:

  • Click on a benefit to edit;
  • Click on "Add another Benefit Feature";
  • Select which feature you want to add on the menu that should open;
  • Configure the feature and save the benefit;

The benefit feature can be afterwards edited and/or deleted, of course. Here are print screens to display the menu to pick the type of feature and an example of a sponsor placement at PSF's sponsor page:

menu

Screenshot from 2021-07-13 11-47-43

logo at sponsors page

Screenshot from 2021-07-13 11-50-18

I'm stuck to the "feature" naming because I couldn't thing about anything better. Help with naming or help texts is always an amazing support for non-english speakers =)

@berinhard berinhard changed the title Feature/benefit features WIP: Benefit Features Jul 13, 2021
FOUNDATION = "psf"
PYCON = "pycon"
PYPI = "pypi"
CORE_DEV = "core"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have other choice fields in the sponsors app, such as sponsorship's status or contract's status. For the sake of integrity, I'd like to refactor them to also use Enum too if you think it's a good idea.

Copy link
Member

Choose a reason for hiding this comment

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

yes! i think this is a wonderful idea!

Copy link
Member

@ewdurbin ewdurbin left a comment

Choose a reason for hiding this comment

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

Thanks for making this concrete. In review I caught the concern highlighted in the comment regarding "BenefitFeature" model that we should probably clarify before moving forward.

Everything else looks great.

requirements.txt Outdated
@@ -1,2 +1,3 @@
-r base-requirements.txt
-r prod-requirements.txt
django-polymorphic==3.0.0
Copy link
Member

Choose a reason for hiding this comment

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

move to base-requirements before merge.

FOUNDATION = "psf"
PYCON = "pycon"
PYPI = "pypi"
CORE_DEV = "core"
Copy link
Member

Choose a reason for hiding this comment

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

yes! i think this is a wonderful idea!

@@ -819,3 +839,33 @@ def nullify(self, commit=True):
if commit:
self.sponsorship.save()
self.save()


class BenefitFeature(PolymorphicModel):
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a suitable base name honestly. "Features" will include:

  • Logo Placements
  • Requirements
  • Deadlines
  • Notifications

So I think this is the best generic term we can really come up with!

@berinhard
Copy link
Contributor Author

berinhard commented Jul 15, 2021

@ewdurbin I think the DB modeling part of this work is done but I guess we have a problem with the build. It's failing due to this error:

ERROR: django-polymorphic 3.0.0 has requirement Django>=2.1, but you'll have django 2.0.13 which is incompatible.

This error wasn't happening in my local env because I've installed the project with pip install django-polymorphic and, thus, the installation proceeded with success. After reinstalling the package with pip install -r dev-requirements, as CI build does, I'm seeing the same error =S

Since we talked this week about upgrading Django version to 2.2 LTS, I think this build error is a new evidence suggesting this. If you're ok with it, I can open a new PR addressing this. If you want to take a look, here are the backward incompatibilities list:

Django 2.2 will be supported until April 2022, which give us enough room to safely schedule a Django 3.0 upgrade too.

* can we also rename the master branch to main?

@berinhard berinhard marked this pull request as ready for review July 21, 2021 18:27
@berinhard berinhard requested a review from ewdurbin July 21, 2021 18:27
@berinhard
Copy link
Contributor Author

@ewdurbin as we've spoken, I've created #1819 to address Django 2.2 LTS upgrade and changed django-polymorphic version to one which doesn't conflict with Django 2.0. Feel free to give this PR a final review and, if you feel everything is on place, merge it. Thanks =)

@berinhard berinhard changed the title WIP: Benefit Features Benefit Features db modeling Jul 21, 2021
@@ -513,6 +530,13 @@ def new_copy(cls, benefit, **kwargs):
**kwargs,
)

# generate benefit features from benefit features configurations
for feature_config in benefit.features_config.all():
feature = feature_config.get_benefit_feature(sponsor_benefit=sponsor_benefit)
Copy link
Member

Choose a reason for hiding this comment

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

I really appreciate that this is a method that can be defined! Will be super helpful in setting up things like "Deadlines" which may be dependent on the date of approval!

"""
raise NotImplementedError

def get_benefit_feature(self, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

For now this is 💯, but it may make sense to leave this as unimplemented and allow for each Configuration to make decisions, although of course they can be overridden in inheritance :)

@ewdurbin ewdurbin merged commit b9d4145 into main Jul 22, 2021
@ewdurbin ewdurbin deleted the feature/benefit-features branch July 22, 2021 16:26
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.

2 participants