Coder Social home page Coder Social logo

svthalia / concrexit Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 11.0 98.2 MB

Thalia Website built on Django.

Home Page: https://thalia.nu

License: Other

Shell 0.19% Python 77.74% HTML 12.33% CSS 0.39% JavaScript 6.41% SCSS 1.66% Makefile 0.50% HCL 0.67% Dockerfile 0.11%
django thalia python hacktoberfest

concrexit's Introduction

Thalia Website

Linting and Testing coverage documentation Code Style Code Climate

The latest Thalia Website built on Django.

Getting started

  1. Get at least Python 3.11 and install poetry >= 1.8.0 and the Pillow dependencies as per below.
  2. Clone this repository
  3. make member to create the first member while in the cloned folder. This will also install all dependencies (in a separate virtual environment)
  4. make fixtures to generate a bunch of test data
  5. make run to run a testing server. Now you are able to visit your local concrexit at http://127.0.0.1:8000
  6. Open the code in your favorite Python IDE (we have some helpful default settings provided for VSCode).

Optional, but recommended: follow the tutorial! It can be found by going to the Wiki (top of the GitHub page) and then clicking on "Your first contribution" or by clicking here.

Useful git commands

  • git push to push your branch to github
  • git switch -c <branch name> to create a branch to work on
  • git fetch origin to synchronize your local repository with the central repository's main branch
  • git switch <branch name> to switch between branches (branch name master is the main branch)
  • git add . to add all your changes to a commit (mind to run make fmt in your terminal before adding changes)
  • git commit (-m <commit message>) to commit your added changes possibly with a message
  • git rebase origin/master to get your branch up to date with all merges
  • git status to check the current status of your branch

Pillow dependencies

Pillow dependencies are used for the thumbnail generation. The website will give lots of errors and work weirdly if you don't install these native dependencies.

For Ubuntu, use:

apt-get install python3-dev build-essential libjpeg-dev zlib1g-dev libwebp-dev

For other operating systems, see the Pillow Documentation.

On macOS you will also need to install libmagic, using the brew package manager by running brew install libmagic.

Contributing: also see the contributing guidelines for more information on how to contribute to concrexit.

Structure

The project is split into multiple apps, each with their own purpose. Those apps have generally the same structure, which is explained below.

  • README.md: general information about the app. This is where you should explain what the app does and how it works on a high level.
  • models.py: contains the database models for the app. This is the core of the app, as it defines the data that is stored in the database.
    • migrations/: contains the database migrations for the app
  • admin.py: contains the admin configuration for the app. This is where the admin interface is configured.
  • urls.py: contains the URLs for the app. If an app exposes an endpoint for users (non-admin), it should be defined here. From here, the views are imported and called. the thaliawebsite app contains the main urls.py file, which imports all the URLs from the apps.
  • views.py: contains the views for the app. This contains the logic for the app that interacts with the models. From here, the templates are rendered and the data is passed to the templates.
  • services.py: for any logic that doesn't properly fit in the views, you can define services. These services should be placed here. Services are procedures (business logic) that we want to trigger from multiple places (views, signals, management commands, admin ...).
  • forms.py: contains the forms for the app. For all user input, a form should be used.
  • templates/: contains the HTML templates for the app. Inside this container, admin forms are placed in templates/admin/ and the rest of the templates are placed in templates/<appname>/. Email templates are placed in templates/emails/ or templates/<appname>/emails/.
  • static/: contains the static files for the app. Inside this container, admin static files are placed in static/admin/ and the rest of the static files are placed in static/<appname>/. Then, for every type of static file, there is a separate folder. For example, CSS files are placed in static/<appname>/css/ and JavaScript files are placed in static/<appname>/js/.
  • admin_views.py: is used if an app has very special, non-default, admin views that would make the admin.py file too big.
  • tests.py: contains the tests for the app. This is where the tests are defined.
  • emails.py: used for sending emails. This is where the emails are defined. Make sure to use the send_email function from the utils app to send emails.
  • tasks.py: contains Celery tasks for the app. Celery tasks are functions that can be run in the background, without blocking the request-response cycle. This is useful for periodic tasks, and anything that's somewhat slow, such as sending emails.
  • apps.py: contains the app configuration for the app. This is where the app is named and the app is configured. Any interaction with other apps should be done here (like defining the site's menu). Generally, you don't have to touch this file.
  • decorators.py: if you define decorators for the app, they should be placed here.
  • exceptions.py: if you define specific exceptions for the app, they should be placed here.
  • signals.py: if you define signal receivers for the app, they should be placed here. Make sure to import the signals in the apps.py file to make sure they are registered.
  • sitemaps.py: if you define a sitemap for the app, it should be placed here. Currently, we simply import sitemaps in the thaliawebsite app, but in the future, we want to register them in the apps.py file like we do with the menu bar items too.
  • management/commands/: if you define management commands for the app, they should be placed here. The management commands are run using python manage.py <command>, which will run management/commands/<command>.py. Keep the code in the management/commands/<command>.py file as small as possible and move the logic to a service if possible.
  • api/<version>/: if you define an API for the app, it should be placed here.
    • api/<version>/serializers.py: contains the serializers for the API. This is where the data is converted to JSON.
    • api/<version>/views.py: contains the views for the API. This is where the API endpoints are defined. From here, the serializers are imported and called.
    • api/<version>/urls.py: contains the URLs for the API. This is where the API endpoints are defined. From here, the views are imported and called. The api/<version>/urls.py file is imported in the thaliawebsite app's api module, which contains the main urls.py file.

Whenever the contents of a single .py file would become too large, we split it up into a module. For example, if the admin configuration for an app would become too large, we create an admin module with multiple files in it. Don't forget the __init__.py file in the admin module, otherwise it won't be recognized as a module, and make sure to import the files from the __init__.py file.

Note that you are not restricted to the filenames above and you can create new files if you think it is necessary. However, make sure to keep the structure consistent.

Data minimization

Apps that contain personal data should implement a execute_data_minimization method to perform data minimization on the data in the app. This method should be called from the execute_data_minimization method in the thaliawebsite app. In the future we should register this method in the apps.py file of the app, but for now we do it in the thaliawebsite app.

API

Versions

We currently have 2 versions of the API. The first version is the v1 API, which is the old API. The second version is the v2 API, which is the new API that is actively being developed. The v1 API is deprecated and will be removed in the future.

Swagger documentation

The API has automatic documentation using Swager / OpenAPI. This documentation is available at /api/docs/.

Authentication

v1 uses token authentication. v2 uses OAuth2 authentication, which is the new standard for authentication. The OAuth2 authentication is implemented using the django-oauth-toolkit package.

Throttling

The API has throttling enabled.

Other (internal) APIs

Apart from the main versions (v1 and v2), we also have a few specific mini-APIs that are used for specific purposes and are not really open to the public. These are the calendarjs and facedetection APIs. The calendarjs API is only used by the calendar on the website (to query events) and the facedetection API is used by the face detection service to post face encodings.

About concrexit

About the name concrexit:

_In July of 2015 we moved from the archaic Thalia-system to a Concrete5-based website where a lot of work had been put into. However, roughly one year later we were discussing our reluctance to maintaining the system that we had build. We had developed an aversion against Concrete5, its community and the horrible documentation (never mention it's maintainer, Andrew Embler). The CMS was never meant to do the job we wanted it to do. Thus we initiated Project #concrexit (Brexit was in the news at that time, update fall 2019: 4 years later it still is) to make things easy and fun again. The name eventually stuck.

Scope

The purpose of this website is to provide a dedicated platform for the members of Thalia. All functionality should be aimed at this goal. This involves things like events and membership registration, event registration, photo albums, ordering food, etc. As a consequence, the website also implements the member administration or a payment system, as this is a core part of the association and is needed for the aforementioned functionality.

Concrexit, however, is not a CMS (content management system) and should not be used as such. Static pages are implemented because they should be integrated, but they cannot be edited through the admin interface (though this would not be hard to implement with django-cms), because this is not the purpose of concrexit. Also, concrexit should not be used as a platform for implementing internal tools for specific (groups of) members. For example:

  • concrexit should not be a repository for the Thabloid
  • concrexit should not implement any bookkeeping tools
  • concrexit should not implement any CRM functionality
  • concrexit should not implement any internal communication tools

Such tools should be implemented as separate applications, which can be integrated with concrexit if needed via the API (for example, like Thadmin). This distinction is important, because it helps to keep the codebase maintainable and prevents feature creep (which is a big problem for concrexit). Concrexit is an important system for the association, and it should be kept as simple as possible to ensure that it can be maintained in the future. We should not try to implement everything in concrexit, but instead focus on the core functionality, and use other tools for the rest.

Apps and dependencies

We try to keep concrexit modular to improve maintainability for the future. So in case certain apps become unmaintainable, they can be worst-case be turned off without breaking any of the other functionality. Also, modular apps are easier to test, easier to understand and generally make the codebase more maintainable. It's just good practice.

The graph below shows the current dependencies between the apps in concrexit.

Note: this graph is not automatically generated! It is manually maintained and might be out of date.

This graph leaves out the thaliawebsite and utils app as they are special apps with a lot of cross dependencies.

graph TD;
    announcements --> events;
    activemembers --> members;
    activemembers --> mailinglists;
    events --> activemembers;
    events --> members;
    events --> payments;
    mailinglists --> activemembers;
    mailinglists --> members;
    newsletters --> events;
    newsletters --> members;
    newsletters --> partners;
    photos --> events;
    pizzas --> events;
    pizzas --> members;
    pizzas --> payments;
    promotion --> events;
    pushnotifications --> events;
    pushnotifications --> members;
    pushnotifications --> photos;
    pushnotifications --> newsletters;
    pushnotifications --> pizzas;
    registrations --> members;
    registrations --> payments;
    sales --> payments;
    sales --> activemembers;
    sales --> members;
    moneybirdsynchronization --> payments;
    moneybirdsynchronization --> registrations;
    moneybirdsynchronization --> sales;
    moneybirdsynchronization --> events;
    moneybirdsynchronization --> pizzas;
    facedetection --> members;
    facedetection --> photos;

    documents;
    partners;
    shortlinks;
    singlepages;
    thabloid;

    %% Current dependencies that are problematic and for which issues exist for fixing
    %% 2757
    documents --> activemembers;
    documents --> events;

    %% #2753
    events --> pizzas;
    events --> promotion;

    %% #2756
    members --> activemembers;
Loading

It is important to note that the dependencies between apps should be kept to a minimum and should be one-way. For example, the members app should not depend on the activemembers app, but the other way around is fine. Underlying apps should be the most robust and stable (for example, the basic functionality of the members app has not changed for years).

External systems

Concrexit runs standalone, but it does integrate with a number of external systems.

  • There is integration with Moneybird for bookkeeping. This is implemented in the moneybirdsynchronization app. Note that concrexit only pushes data to Moneybird, it does not read any data from Moneybird.
  • Concrexit pushes to Google Workspace (specifically, groups). This is implemented in the mailinglists app. Note that we only push the groups, any other settings are not managed by concrexit and should be managed in Google Workspace directly. Neither are changes to the groups in Google Workspace pushed back to concrexit.
  • There is a tight integration with Thadmin, a user-friendly Point of Sale system for Thalia that implements Thalia Pay. This is implemented in the sales app.
  • Face detection makes use of an AWS Lambda function, which is implemented in the facedetection app and concrexit-facedetection-lambda.
  • Of course, the ThaliApp is also an external system that integrates with concrexit. Specifically, the pushnotifications app implements unique functionality for the ThaliApp.

In the future, we might want to integrate with other systems, such as:

  • Mailchimp for sending newsletters (instead of using the newsletters app, which is hard to maintain and not very user-friendly)
  • A more advanced integration with Moneybird
  • A more advanced integration with Google Workspace

concrexit's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

concrexit's Issues

Partner events

In GitLab by @lscholten on Aug 13, 2016, 11:48

Like in the previous website, it must be possible to create partner events. It is advisable to wait until events is merged, then work on this.

Several static-content pages

In GitLab by @joostrijneveld on Jul 6, 2016, 20:30

Some of our pages are trivially filled with static text. These can be combined in a single package, or go into the thaliawebsite package. Consider if flatpages is a good idea, whether we want to roll our own, or simply hardcode the relevant content in template files.

Relevant pages;

  • Contact
  • 'Become a member' (although potentially part of the members app)
  • Sister associations
  • 'Become an active member' (although potentially part of the active members app)

Extra controls for photos

In GitLab by @joostrijneveld on Aug 4, 2016, 22:42

It would be nice if the mediacommittee could

  • Delete existing photos
  • Rotate existing photos
  • Toggle album visibility

Adding photos to an existing album already works by submitting a new zip file.

Upload meeting documents to meeting-unique directory

In GitLab by @joostrijneveld on Aug 11, 2016, 16:04

This should avoid duplicate names that get a nonce appended, but is non-trivial because meeting.pk does not exist in the upload_to handler yet, and basing it on meeting.date can cause problems and confusion when the date is changed. EDIT: Turns out this does exist, because of the ForeignKey relation.

'Become a member'-page

In GitLab by @joostrijneveld on Jul 26, 2016, 22:27

It would be good to do this after merging !8 so that the misc. documents can be used here. It probably makes sense to create a singleton model, perhaps using django-solo.

It probably still makes sense to place this in the 'members' app.

Newsletter

In GitLab by @joostrijneveld on Jul 31, 2016, 10:51

We should be able to send the newsletter from within the admin backend

Delete files when models deleted?

In GitLab by @joostrijneveld on Jul 14, 2016, 21:45

There seems to be an easy system-wide way to accomplish this by installing django-cleanup, but is this something we want for every FileField and ImageField? Is there a scenario where we might reference the same logical file from two models?

Oude commissies en commissieleden weergeven

In GitLab by @thomwiggers on Jul 27, 2016, 22:52

Afgesplits van #13

  • Het zou leuk zijn een overzicht van voormalige commissies te hebben met hun oud-leden.
  • Het lijkt een goed idee om (verkleind) een lijst van oud-leden van commissies onder de commissie te zetten.

Administratietrucjes

In GitLab by @joostrijneveld on Jul 31, 2016, 10:51

The admin panel should include forms to perform the admin tricks necessary e.g. at the start of the year.

  • Welcome email / Custom create user form
  • Email about upcoming direct debit
  • Email expiring members
  • Email non-expiring members
  • Collect information for direct debit
  • Send email to members requesting they check their information
  • Download address stickers

Events

In GitLab by @joostrijneveld on Jul 6, 2016, 20:23

Requirements wordt aan gewerkt in !21

  • Events aanmaken
    • Extra informatievelden
    • Aanmeldingen
    • Organisatorveld
  • Aanmeldingen weergeven
    • Met de hand aanmelden
      • leden
      • niet-leden
    • Aanwezigheidregistratie (#52)
    • Export aanmeldingen (#53)
      • met informatie
  • Events weergeven (#54)
    • Agendaoverzicht
    • iCal feed
    • Evenement view
    • Deelnemers laten zien iff ingelogd
    • Aanmelden
      • Alleen huidige leden laten aanmelden
    • Afmelden
      • Afmelden na de deadline: thalia/website#390

Migrate ALV documents

In GitLab by @joostrijneveld on Aug 10, 2016, 19:14

As there are quite a few of these, doing this manually without errors is not realistic. Exporting JSON from concrete5 is an option; scraping from the live website is much more fun.

Tightly couple django and mailman

In GitLab by @joostrijneveld on Aug 5, 2016, 10:26

Issue #25 implements the old API that gets called in a cronjob, firing a Python script that talks to it over HTTPS. We could replace this:

  • either by a cronjob Python script that queries the database directly
  • or by a save() handler that updates mailman when MailingList changes
  • or at the very least by a more nicely separated API with less GET variables (i.e. not one url route)

Partners

In GitLab by @joostrijneveld on Jul 6, 2016, 20:24

Global to-do list (will be expanded when necessary)

  • Partner page
  • HTML editor for partner profile
  • List of partners, with random ordering and main partner in own section
  • Partner vacancies
  • Vacancy categories
  • Vacancies of non-partner
  • Vacancies on partner page
  • Random list of images for partner headers
  • Allow override of large header (below menu) by partner provided header
  • Add useful information to admin lists

Merchandise

In GitLab by @joostrijneveld on Jul 6, 2016, 20:25

Ideas: create a single model that has an ImageField (see documents application for similar FileField), do not bother with thumbnails but simply render this image. For multilingual description fields, use description_en and description_nl ("Explicit is better than implicit")

Outgoing email

In GitLab by @joostrijneveld on Jul 31, 2016, 10:57

It would be awesome to link outgoing email to Thalia user accounts. This likely requires some advanced SASL magic, though.

Fotoalbums delen met niet-leden mogelijk maken

In GitLab by janmartens on Feb 1, 2016, 11:35

Zo hebben we bijvoorbeeld foto's gemaakt bij de diploma-uitreikingen, nou wil je deze foto's niet in het bijzonder openbaar maar we hebben wel enkele requests gekregen van mensen of ze de foto's in konden zien. Dit kan momenteel niet als ze geen Thalia-login hebben.

Hetzelfde geldt voor de MeetINN, Docentenborrels en activiteiten samen met andere studieverenigingen.

Een oplossing zou kunnen zijn om fotoalbums openbaar te kunnen maken, maar dan zijn ze wel door de hele wereld te bekijken en dat is ook niet perse wenselijk.

Thabloid

In GitLab by @joostrijneveld on Jul 6, 2016, 20:22

  • let the user upload a PDF
  • serve it back to users (maybe through 'sendfile' for consistent naming, see documents app)
  • display a thumbnail
  • ideally cut it up into JPGs
    • and use a fancy viewer if there's time (alternatively: outsource this to a new issue).

For the thumbnail, see conclusions that come out of #2 (potentially a dependency that is able to turn the uploaded PDF into a JPG front cover).

Commissie backend

In GitLab by @thomwiggers on Jul 6, 2016, 21:30

Uitzoeken hoe het commissiesysteem werkt en integreren met groups

  • integreren met permissiemodel
  • Commissiegegevens volgen:
    • beschrijving
    • foto
    • permissies
    • oprichtdatum
    • einddatum
    • contactadres
  • Besturen ook representeren
  • Memberships opslaan
  • sinds
  • tot
  • voorzitter
  • manipulatie memberships fixen
  • if voorzitter verandert moet het een nieuw membership worden en het oude deactiveren.
  • Verlaten van een commissie moet niet het deleten, maar het inactive maken (misschien maar gewoon met de hand doen though)

Make uploading photos a bit nicer

In GitLab by @joostrijneveld on Aug 5, 2016, 11:58

Currently we upload a zip that gets sent over a simple form. This may cause issues when things time out or get interrupted. Instead, something more fancy using Javascript and HTML makes this much more convenient. Consider also checking which files already exist, e.g. when an upload is interrupted (although duplicate detection is hard).

Photos

In GitLab by @joostrijneveld on Jul 6, 2016, 20:22

Remaining tasks:

  • Download link icon is broken
  • Create a way to add photos
  • Fix pagination

Migrate members

In GitLab by @joostrijneveld on Aug 5, 2016, 16:07

This issue keeps track of everything we need to pay attention to when migrating the members.

  • Memberships have been expanded. Use the current membership types + joining years as starting points, and fix individual members as appropriate.
  • 'registration year' is now 'starting_year'; this is the year someone started studying, but not necessarily the year they joined Thalia. However, for lack of information, during migration we only have one year value to work with..
  • We will need to re-hash the passwords. We can probably do this without resetting everyone's passwords.
  • Add migration instructions to migration.md

Pizza application

In GitLab by @joostrijneveld on Aug 13, 2016, 13:11

Notes:

  • Hardly needs to interact with events (only for back-referencing)
  • Prevent overlapping pizza events such that only one is active at a given time
  • Create a page that lists current orders, for easy payment toggling during events

Display Thabloid pages in a fancy Javascript viewer

In GitLab by @joostrijneveld on Aug 7, 2016, 16:52

We have all the back-end materials we need (i.e. a collection of accessible JPGs for every page). Find a nice Javascript viewer to display the Thabloids in a lightbox. URLs and model hooks are available since !26.

I've looked at turn.js but could not get it to play nicely - I got annoyed with Javascript and CSS. Might still be worth a shot for someone more perseverant.

Create more appealing document thumbnails

In GitLab by @joostrijneveld on Jul 26, 2016, 20:19

Setting up PDF-to-thumbnail was not considered not to be worth the hassle. Some static images with a Thalia logo would suffice. Perhaps we do want to create dynamic PNGs based on the specific year, for association documents..

Commissies front-end

In GitLab by @thomwiggers on Jul 13, 2016, 16:18

  • Commissies overzichtspagina op de website
    • actieve commissies
    • oud-commissies?
  • Commissiepagina's per commissie

`static/COMPILED` wordt niet vanzelf gemaakt

In GitLab by @joostrijneveld on Jul 14, 2016, 23:03

Sinds we LESS willen compilen moet de map static/COMPILED (blijkbaar) bestaan, anders loop je tegen deze fout aan:

StaticCompilationError at /
Error: ENOENT, no such file or directory 'concrexit/website/static/COMPILED/css'

Kunnen we niet checken of die map bestaat wanneer je opstart, en 'm aanmaken als dat nog niet zo is? Dat zou bijvoorbeeld eenvoudig in de algemene site-app kunnen, in de AppConfig.ready()..

Maar @thomwiggers en @lscholten hebben hier gister tijd aan besteed, dus misschien gedachten hierover voordat ik 't probeer te fixen? Liepen jullie hier niet tegenaan? Moest je met de hand mkdir static/COMPILED uitvoeren?

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.