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

Make Area model configurable #44

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

Conversation

PeteCoward
Copy link
Member

@PeteCoward PeteCoward commented Jul 24, 2024

This is intended to allow an implementing project to say, hey I'd love to use simple_locations, but I want my location model to have an extra field, maybe an extra field to the django Group model for example, or an alternative code.

Not fully tested in implementing project as yet, but here I have

  • separated out AbstractBaseArea / AreaType / Point / ProjectedArea / Border
  • methods to get an abstract base class for each from an implementing project, from which that project can inherit a model of it's own taking advantage of the features
  • intention is to include simple_locations as a dependency, but NOT an installed app
  • (migrations updated simple locations id fields to BigAuto)

@PeteCoward
Copy link
Member Author

draft until I test it more in a project

@PeteCoward
Copy link
Member Author

PeteCoward commented Jul 24, 2024

This has issues ...

It produces migrations in simple locations because simple locations picks up the configured model, and removes its own Area model and updates the Fk fields of the other models to match.

I think I'll have to explore removing simple locations from my INSTALLED_APPS, but keeping the dependency, and overwriting the required bits on inherited models

@PeteCoward
Copy link
Member Author

Promising so far, example use is

from simple_locations import base_models as sl_bases


class PlaceType(sl_bases.AbstractBaseAreaType):
  class Meta:
    verbose_name = _("place type")
    verbose_name_plural = _("place types")

class Point(sl_bases.AbstractBasePoint):
  class Meta:
    verbose_name = _("place type")
    verbose_name_plural = _("place types")

PlaceBase = sl_bases.get_area_base(PlaceType, Point)
class Place(PlaceBase):
  groups = models.ManyToManyField(Group, related_name='groups')
  class Meta:
    verbose_name = _("place")
    verbose_name_plural = _("places")

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.

1 participant