conoscerelinux / asso-django Goto Github PK
View Code? Open in Web Editor NEWAn open source Django Framework to manage Events, Member and basic Accounting for an Italian Association
License: GNU General Public License v3.0
An open source Django Framework to manage Events, Member and basic Accounting for an Italian Association
License: GNU General Public License v3.0
They are related to transaction and the process of Member registration. They should manage a Member who is registered and calling for Membership creation or renovation.
More clarification and documentation is needed on how they should work
MembershipRegister
? It's really needed?production and development requirements are at the moment separate files.
This was made to accomplish a common pattern in my personal projects which became obsolete after introducing pyproject.toml
as python project management file.
requirements.txt
pip install .
to install production dependenciesData should be loaded with a single script load_data.py
which load a sample site and sample data
A possible solution is to create a requirements.conda.txt
or simply test our requirements in a conda environment (exploiting conda support to multiple python versions)
NOTE: in the unfortunate event that a UserMail.mail coincide with a User.mail (maybe for some strage internal error or an admin oversight), User.mail will have always precedence over UserMail.mail with this setup
TBD: improve issue description
TBD: Split the project in a list of specific action
-f
in bootstrap-django
command (rm-f db.sqlite3
)freeze
in requirements
python-codicefiscale
permits to check personal data against member's codice fiscale
We could use it as a custom django validator to ensure data insertion is formally valid
see https://github.com/fabiocaccamo/python-codicefiscale for more info
For reference see documentation
core/models.py
to core/models/__init__.py
core/models/user.py
)core/models/common.py
__init__
for backward compatibility"Codice Fiscale" field should be unique as it represent the unique ID of a person in Italy
There are two main problems:
python-codicefiscale
has a good solution but in general is a best effortMember
to check if Member.cf
is valid (see #50 )Member
to check if Member.cf
is unique unless Member.skip_cf_valid=True
Actually project has this structure (as presented in Django tutorial)
asso-django/
admin/
academy/
common/
...
website/
manage.py
Django REST Framework propose another way
asso-django/
admin/
academy/
common/
...
website/
manage.py
This way all apps are contained inside admin package (which could be called asso
)
Also this structure permits to convert common app (which is never used as app) in a normal python module
When textual data migrated miss a value or is set to None, it should add it as empty string.
To pass full_clean check the parameter exclude can be used
for field in textual_field_name:
if not field in item or field is None:
item[field] = ""
exclude = [field for field, value in item.items() if value is ""]
member.full_clean(exclude=exclude)
TimePeriod describe a formal timeframe of membership validation
For example a membership record on 10th of February 2023 should be valid throught 1st of January 2023 to 31th of December 2023 if the formal timeframe chosen by association is the solar year for members registered in 2023
@ZompaSenior has proposed to implement it with a start and a duration (using RelativeDeltaField field)
class TimePeriod:
start = models.DateField(...)
duration = models.DateField(...)
price = models.MoneyField(...)
An additional end=models.DateField(...)
field could be added with a validation which impose that one and only one between duration or end field should be set. Or substituting duration
with end
. This should permit more fine selection of date interval, but make more complex to set regular interval (yearly, bimonthly, etc, etc)...I think response is obvious
TimePeriod.duration == None
could be used to intend a membership which doesn't endTimePeriod.start == None
could be used to intend a membership which is retroactively always validprice
is referring to, as is I think is the default price to create a membership for that period. In fact discounted or free memberships should be permits. I think this last observation is linked to logic inside Transaction connected to membership model@giobber it could be great if you can provide some instructions on how to use your installation system, if you think it could be the main way to perform.
Otherwise we can collect together some instructions for a more general way.
In my opinion, it is possible to avoid inserting the field relating to the date and times of an Event in the model of the Event itself, as this information can be indicated in its first Session.
In fact, barring logical wreckage, in the case of multiple Sessions of an Event, it would still be necessary to indicate the information for each Session, including the first, so in my opinion you could simply make sure that you always have a first Session automatically generated with information relating to the date and times, and then be able to add more if necessary.
In this mode, the sorting of Events on the site could be based directly on the dates of the Sessions, and also allow logics in which Events can remain visible, if Sessions are yet to take place (perhaps with an option that allows you to avoid it when no appropriate).
documentation: https://django-jazzmin.readthedocs.io/
github: https://github.com/farridav/django-jazzmin
pip: https://pypi.org/project/django-jazzmin/
This issues contains all the info to complete Membership model
MembershipPeriod
fields__str__
by making it fallback to f"{start}-{end}"
Moved to issue #69
__str__
(for example f"{str(self.period)}/{self.card_number}"
Django normalize_email
doesn't force email to be lowercase or point insensitive before @ symbol
For more info see: https://stackoverflow.com/questions/74754013/is-there-an-efficient-way-of-preventing-the-same-email-addresses-registered-with
normalize_email
which convert email to a lowercase version without point or other strange symbolOne of the ways to extend a model in django is via inheritance, essentially when i subclass a model in django it create a hidden OneToOneField relation (unique=True, primary=True, null=False) by using Base class index as index for children.
For more info see Django Documentation
first_name
, last_name
and email
now are set and accessed between User, Member and Teacher without useless complicationsfrom ..core.models import User
class Member(User):
...
Implement a "Soft Deleting" logic
jazzband library implement a solution: https://django-model-utils.readthedocs.io/en/latest/models.html#softdeletablemodel
On membership saving user personal data should be saved inside membership to preserve the state over the years
This is needed to show in membership table the right given data on each MembershipPeriod
(Libro dei Soci should not change over time in case we need to regenerate it)
python-codicefiscale
permit to check if Codice Fiscale is compatible with personal data
This can be done inside the view or as a Member validator. The first one IMHO is the more feasible way to use it.
Implementation could be done as a class method check_cf_data
NOTE: Only problem with this is that python-codicefiscale
require birth city written in a very specific way, but admits variations. So we can check if data inserted by user is compatible with a variation and substitute it with the library's chosen one.
Make login available with multiple user emails and username
class User(AbstractBaseUser):
username = models.CharField(max_length=40, unique=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
password = ...
USERNAME_FIELD = "username"
objects = UserManager()
@property
def email(self):
return self.emails.filter(primary=True).first()
class UserEmail(Model):
email = EmailField(unique=True)
user = ForeignKey(User)
primary = BoolUniqueForUser() # Mail used for communications
# Inside membership module
from django.conf import settings
from django.contrib.auth import get_user_model
class Member:
...
user = OneToOneField(settings.AUTH_USER_MODEL)
...
link to documentation
models.py
, admin.py
, 'migrationsand
apps.py`auth_user
tableapps.py
with name admin.auth
admin.auth.apps.AuthApp
to settings.INSTALLED_APPSIf this not work (and probably will) take a breath, remove all migrations for user and memberships and start anew (fortunately we are still in alpha), the other models migrations will live fine
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.