Giter VIP home page Giter VIP logo

member-database's Introduction

member-database CI codecov

Our member database application.

This is a custom database application and webinterface for membership and event registrations for PeP et al. e.V.

Hosted at registration.pep-dortmund.org.

Design Choices

  • keep it simple
  • keep it maintainable
  • proven technologies > fancy stuff
  • use things that we know

therefore we want to use

  • poetry (dependency management, packaging, virtualenv)
  • sqlite or postgresql (database)
  • flask (API)
  • itsdangerous (token-based authentication)
  • sqlalchemy (ORM)
  • if we don't know what to do: follow the flask mega tutorial
  • Server-side rendering (flask templates) for the ui with a little sprinkle of client-side js and KaTeX for math

Development

We strongly recommend to read through the first chapters of the the flask mega tutorial

  1. Install python (>=3.6) and make sure you have pip

  2. install poetry using pip install poetry, if you use your system's python, use pip install --user poetry

  3. Install the dependencies using poetry install

  4. copy env-template to .env and fill the variables with the appropriate information

For the mail settings, you can either use your own mail account or just use DEBUG mode, which will log email text but not actually send it.

  1. To initialise the database, run
$ poetry run flask db upgrade
  1. To populate the database with some test user admin with password testdb and 2 test events, run
$ poetry run python populate_database.py
  1. Start the server using FLASK_DEBUG=true poetry run flask run

Code Style

We use Black to have a opinionated and deterministic code style. To not forget to use black, you can install the pre-commit hook:

$ poetry run pre-commit install

This will automatically run black before you commit and aborts the commit if the code does not follow the black code style. This allows you to add the formatted files to the commit.

Runnig the tests

We are using pytest to test our app, see https://flask.palletsprojects.com/en/1.1.x/testing/.

To run the test, use

$ poetry run python -m pytest --cov database

The test results will be printen on the console. To get an idea what tests might be missing you can also view per-line information in the browser by running

$ poetry run python -m pytest --cov database --cov-report html
$ cd htmlcov
$ python -m http.server

Adding Users

To authenticate to certain endpoints you need to add a user. The simplest way for now is to do this interactively in an iPython shell.

  1. Fire up iPython via poetry run ipython

  2. Setup the global namespace with everything you need

    In [1]: from member_database import app, db
    In [2]: from member_database.models import Person, User
  3. Every User needs to be linked to a Person, so first you need to create a person, and store it in the database

    In [3]: p = Person()
    In [4]: p.name = 'Albert Einstein'
    In [5]: p.email = '[email protected]'
  4. Now you can create a User and set its password

    In [6]: u = User()
    In [7]: u.person = p
    In [8]: u.username = 'aeinstein'
    In [9]: u.set_password('supersecurepassword')
    
    # you can even check the super secure hash of this password
    In [10]: u.password_hash
  5. Finally store everything in the database

    # this is needed to connect to the correct database
    In [12]: app.app_context().push()
    
    In [13]: db.session.add(p, u)
    In [14]: db.session.commit()
  6. You can now login at the /login endpoint 🎉

Adding Roles

To enable fine-grained access management for users to specific endpoints, each protected endpoint is associated with a uniquely named access level. A role combines multiple access levels and multiple roles can be assigned to different users. All access levels that are currently available will be added to the database automatically at app startup. Just like in the above example, you can fire up an ipython session and...

  1. To create a new role with some access levels run

    from member_database import app, db
    from member_database.models import Role, AccessLevel
    admin_role = Role(id='admin')
    admin_role.access_levels = [
        db.session.get(AccessLevel, 'get_persons'),
        db.session.get(AccessLevel, 'get_members'),
    ]
    db.session.add(admin_role)
    db.session.commit()
  2. You can simply assign a role to a user via

    from member_database import app, db
    from member_database.models import Role, User
    user = User.query.filter_by(username='aeinstein').first()
    user.roles.append(db.session.get(Role, 'admin'))
    db.session.add(user)
    db.session.commit()

Now, the user aeinstein will have access to the get_members and get_persons access levels via the admin role.

member-database's People

Contributors

beckstev avatar bixel avatar dependabot[bot] avatar karlschiller avatar kevin2 avatar larsbollmann avatar lena-lin avatar marschmitz avatar maxnoe avatar stefangri avatar the-ludwig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

larsbollmann

member-database's Issues

Enable event access via some short link

For memorable, human readable names:

E.g. registration.pep-dortmund.org/events/soak20/registration

This could be implemented by e.g.:

@events.route('/<name: str>/registration')
def registration_by_name(name):
    event = Event.query.filter_by(shortlink=name).first()
    return event_registration(event.id)

Add a homepage

Homepage should include links to

  • events
  • gdpr request
  • pep main page

What do we want to achieve?

Some Ideas of the meeting in Essen and before:

  • Let members change their data (employer, email-address etc.)
  • Easier access for us, add new members, edit, customized mails etc.

Registrtation test

  • AG Schneider counts as E4b?
  • email@test is possible, could it be checked for . in domain?
  • if the external place is chosen, maybe there is a place to specify where it was written

Resend email button

The error notification for "You are already participating" should have an option to resend the email

SEPA Mandate

Members should be able to give us a SEPA Mandat

No error hint in form

I gave number of guests > max but got not warning what was wrong, just a page reload without any indication.

Implement data request

Add the possibility to send a mail or mail with pdf attachment containing all information we have about a member on request. (GDPR data request)

  • Add an endpoint with method post and form data email.

  • Add a template for the email

  • Write the queries that dump all data we have for a Person

Cool name

The member-database needs to have a very cool name so people will love it!

`ledger-mode` aka eternal DB entries

I suggest providing a ledger-mode, i.e. if you want to change an entry, you create a copy with all desired modifcations, link it to the "old" entry and then set the old entry to "archive". This way we can easily get a nice log of all changes in the BD / our member's data (names, adresses, payment history, whatever)

👍 or 👎?

Add "request token" button to login page

The login button is relatively dominant in the navigation bar. Registrants could expect this button to provide some login for their registrations as well. So maybe for now we could just add a email-field in the login form to request a main containing links to all active registrations for that email.

missing Datenschutzerklärung

Datenschutzhinweise bei

  • Jeder Veranstaltung (Auf jedem Formular ist genau anzugeben, welche Daten zu welchem Zweck verarbeitet werden)
  • Vereinsanmeldung
  • Dokument mit Datenschutzerklärung

Create different User groups

Users should have the right to see every information of the database. Grouping of users with same rights could help in that matter

Enable basic auth for api endpoints

Currently it's not possible to get data using commandline utilities like curl or httpie, even requests sessions do not work.

something like curl -u <user> <url>/members should work and would make testing during developement much easier

Add Footer

It is especially hard on mobile, to click the submit button of registration forms due to the bottom spacing. Simply adding some whitespace, i.e. a footer might already help.

Modularize vuejs part

So right now an individual vue-app is added for each input field:

document.querySelectorAll('[type="latex"]').forEach(function(item){
vueApps[item.id] = new Vue({
el: '#input_group_' + item.id,
data: {
title: item.value,
},
computed: {
title_html: function(){
return toTex(this.title);
}
}
})
});

This works of course, but at some point it would be nice to modularise this a little bit more.

One could think of input field connections like in the old PARS interface: You select the "Bachelor" degree and the title of the thesis field becomes "Bachelor-thesis" 😎

This is very low priority of course.

The edit form does not return a response

Currently, the gdpr request email points to a edit form that does not return a response, see

if form.validate_on_submit():
p.name = form.name.data
if p.email != form.email.data:
p.email_valid = False
p.email = form.email.data
p.date_of_birth = form.date_of_birth.data
p.membership_pending = form.membership_pending.data
db.session.commit()
flash(_('Ihre Daten wurden erfolgreich aktualisiert.'))
return redirect(url_for('main.edit', token=token))
@main.route('/view_data/<token>')
.

SQL vs. NoSQL

A member database sounds quite like a classical use case for SQl.

Please discuss.

Multiple emails per person

A single Person might use multiple emails.

We should enable:

  • A person to have a primary and multiple secondary emails (via a SecondaryMails table)
  • Merging of persons after confirmation of the secondary mail

Licence

Which license? Is there any PLP (PEP Licence Policy)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.