Skip to content

Commit

Permalink
Merge pull request #231 from membermatters/dev
Browse files Browse the repository at this point in the history
v3.5.0
  • Loading branch information
jabelone authored Jan 6, 2024
2 parents 4abbc81 + fd4f8ce commit ae09772
Show file tree
Hide file tree
Showing 78 changed files with 4,270 additions and 2,022 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v3.5.0] - 2024-01-06

### Removed

- Some unused Django constance settings
- Logged in route guard from webcams page so it's properly public
- All old interlock code from the http api days

### Added

- Moodle support / integration for onboarding induction as part of signup flow
- Proper api key support for various api endpoints with djangorestframework-api-key
- Auto commission new `AccessControlledDevice`s
- Manual device sync, reboot, bump buttons
- Support for websocket interlocks
- Support for vending machine debits via websocket
- Dynamic SpaceAPI endpoint based on new models (thanks @proffalken)
- More detailed email logging
- More detailed access system logging
- Device level loggins for connections, disconnections and authentications etc.
- Member is cancelling email notifications / logging
- Support for Google Analytics GA4 tags / google tag manager
- First subscribed date
- Auto refresh on devices page

### Changed

- Overhauled / refactored email system to be more reliable/reusable
- Member signing back up copy makes more sense
- Disconnect websockets if any packet received before auth packet
- Refactored swipe stats to use Django ORM rather than raw queries
- Optimised some queries to make some pages load faster
- All tab-based UIs to be more consistent
- Update MM users

### Fixed

- Some duplicated/strange translation strings
- Spaceapi constance fields updated to use floats for location lat/lng (thanks @proffalken)
- Card last 4 digits not showing on manage member screen
- Edge case that allowed some people to complete signup without subscription
- Order of logs displayed on admin pages to start with most recent
- A bug when members last seen is empty
- Member created date not visible in Django admin
- Various display bugs in manage member screen
- Some admin pages not showing useful names for entities
- Stripe webhook returning error if user has access to an interlock without a serial number
- Canvas not syncing due to another API change
- Fixed 404 in docs (thanks @plex3r)

## [v3.4.1] - 2023-09-01

### Added
Expand Down
11 changes: 11 additions & 0 deletions MemberMatters.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "../mainboard-firmware"
}
],
"settings": {}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ directory. This installs and configures the pre commit hooks automatically. Afte
when you try to commit a file (for example, with `git commit -m "update thing"`).

### Vue.js JavaScript frontend
Please see the [readme](frontend/README.md) file inside the `frontend` folder. This folder contains all of the source
Please see the [readme](src-frontend/README.md) file inside the `src-frontend` folder. This folder contains all of the source
code and other assets needed by the frontend.

### Django Python backend
Expand Down Expand Up @@ -84,4 +84,5 @@ Feel free to add your organisation to this list (via a pull request) if you're a

* [Brisbane Makerspace](https://brisbanemaker.space) (October 2021) - A community workshop for makers in Brisbane, with a focus on high quality tools.
* [HSBNE Inc](https://hsbne.org) (January 2020) - A hackerspace based in Brisbane, QLD.
* [Make Monmouth](https://www.makemonmouth.co.uk/) (November 2023) - A community makerspace based in Monmouth, Wales, UK
* [SparkCC](https://www.sparkcc.org) (September 2021) - A community of makers on the NSW Central Coast
6 changes: 3 additions & 3 deletions docs/POST_INSTALL_STEPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ However, as noted below, currencies will use a hardcoded value set by a configur
### General
* "SITE_NAME" - Name of the website.
* "SITE_OWNER" - Name of the organisation running this website.
* "GOOGLE_ANALYTICS_PROPERTY_ID" - Enter your Google Analytics Tracking ID to enable Google Analytics Tracking.
* "GOOGLE_ANALYTICS_MEASUREMENT_ID" - Enter your measurement ID to enable Google analytics. Only the new GA4 measurement IDs are supported. It should look something like G-XXXXXXXXXX.
* "API_SECRET_KEY" - Secret key used to authenticate some requests from access control devices.

### Signup
Expand Down Expand Up @@ -118,7 +118,7 @@ You cannot currently enable specific events, you either get "all or nothing".
### URLs
* "SITE_URL" - publicly accessible URL this instance of MM is available on.
* "MAIN_SITE_URL" - the main website of the organisation.
* "INDUCTION_URL" - used in the email sent to new members so they can signup for inductions.
* "POST_INDUCTION_URL" - where to send members after they've completed the online induction (typically used to book appointment to collect swipe card).

### Memberbucks
* "MEMBERBUCKS_MAX_TOPUP" - a hard limit on the maxmimum amount a member can add in one go to their MemberBucks account.
Expand Down Expand Up @@ -158,7 +158,7 @@ You cannot currently enable specific events, you either get "all or nothing".
* "TRELLO_ID_LIST" - [Deprecated]

### Space Directory
* "ENABLE_SPACE_DIRECTORY" - enable a space directory compliant API. The various configuration options in this section should be self explannatory.
* "ENABLE_SPACE_DIRECTORY" - enable a [space directory compliant API](https://spaceapi.io). The various configuration options in this section should be self explanatory, however there is also an [API Endpoint](/docs/SPACEDIRECTORY) to update certain fields.

### Theme Swipe Integration
* "THEME_SWIPE_URL" - a URL to hit on each door/interlock swipe that can trigger a theme song played over your intercom system, or something else.
Expand Down
191 changes: 191 additions & 0 deletions docs/SPACEDIRECTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Space Directory

The Space Directory functionality is provided via the [SpaceAPI](https://spaceapi.io) format.

## Reading the data

Any system can read the current information about the space by calling `https://<your_membermatters_installation>/api/spacedirectory/`.

By default, this returns the following data:

| Name | Description | Configuration Location |
|------|-------------|------------------------|
| space| The name of the space | Constance Config (Django Admin pages) |
| logo | The uri of the space logo | Constance Config (Django Admin Pages)|
| url | The URL of the membermatters installation | Django Base URL |
| contact | Contact information, including email and various social media handles | Constance Config (Django Admin Pages)|
| spacefed | Details of whether the Federated Hackspace Authentication service is running | Constance Config (Django Admin Pages)|
| projects | A list of projects that the space is involved in | Constance Config (Django Admin Pages)|
| issue_report_channels | What's the best way to report an issue? | Constance Config (Django Admin Pages)|
| state | Is the state open or closed, and what message should we display? | Dynamic (Django Admin or API Endpoint) |
| icon | An icon for each of "open" and "closed" | Constance Config (Django Admin Pages)|
| api_compatibility | The version of the [SpaceAPI](https://spaceapi.io) that we are compatible with (can be multiple values) | Hard-coded based on Member Matters release version |
| sensors | A dictionary of sensor data (and associated properties where relevant) as described in the [SpaceAPI JSON Schema documentation](https://spaceapi.io/docs/#schema-key-sensors) | Dynamic (Django Admin or API Endpoint) |
| location | The physical location of the space including latitude and longitude | Constance Config (Django Admin Pages)|

The data is returned as a JSON document.

For tools that can help you interact with the data to display your current state on your homepage etc, visit the [SpaceAPI Tools](https://spaceapi.io/how-to-use/) page and have a play!

## Updating the data

For anything in table above that is marked as "dynamic", you can update that information via the API.

Simply `POST` a JSON document to `https://<your_membermatters_installation>/api/spacedirectory/update` as an authenticated user, and the relevant fields will be updated.

### Updating the status and the message

Let's say you're opening the space and you want to ensure that everyone knows it's an "Open Night" (i.e. general public are welcome, not just members).

You can do this with the following command:

```bash
curl -X POST -H 'Authorization: Api-Key <Your API KEY>' \
-d '{"is_open": true, "message": "Open Night TONIGHT! All Welcome between 1800hrs and 2300hrs"}' \
https://<your_membermatters_installation>/api/spacedirectory/update
```

### Adding Sensor Data

[Sensors](https://spaceapi.io/docs/#schema-key-sensors) are a really cool part of the SpaceAPI schema, as it allows you to publish all kinds of things from how many drinks are still in the fridge through to environment readings such as temperature, windspeed, and humidity.

By default, MemberMatters exposes the total number of active members and how many have "signed in" to the space, however you can add your own sensors as long as they conform to the appropriate type.

To update a sensor or property value, you just need to POST the appropriate JSON to `https://<your_membermatters_installation>/api/spacedirectory/update` as laid out below.

**NOTE**: If a sensor or property is missing from the database then it will be created. If it exists but the value is not included or changed, it will not be updated.

#### Sensors *without* properties

Many of the sensors do not have any extra properties. Updating these is simple, as you just need to send a JSON array of dicts with the correct fields filled out:

```json
{
"sensors": [
{
"type": "temperature",
"name": "test_sensor",
"location": "default",
"description": "This is a sensor",
"unit": "°C",
"value": 21.0
}
]
}
```

Want to update more than one sensor at a time? No worries, just add to the array:

```json
{
"sensors": [
{
"type": "temperature",
"name": "test_sensor",
"location": "default",
"description": "This is a sensor",
"unit": "°C",
"value": 21.0
},
{
"type": "humidity",
"name": "test_sensor",
"location": "default",
"description": "This is a sensor",
"unit": "%H",
"value": 45.0
}
]
}
```

#### Sensors *with* properties

For those sensors that do have properties, only a few extra fields are required:

```json
{
"sensors": [
{
"type": "wind",
"name": "wind_sensor_01",
"location": "The Roof",
"description": "A weather station",
"properties": [
{
"name": "gust",
"unit": "m/s",
"speed": 5.0
}
]
}
]
}
```

As with the sensors, additional properties can be created by adding more dictionaries to the properties array:


```json
{
"sensors": [
{
"type": "wind",
"name": "wind_sensor_01",
"location": "The Roof",
"description": "A weather station",
"properties": [
{
"name": "speed",
"unit": "m/s",
"speed": 5.0
},
{
"name": "gust",
"unit": "m/s",
"speed": 9.0
}
]
}
]
}
```

### A full example

The following JSON updates the space status to "Open", sets a message advising that there is a workshop running that evening, and sets the values for various sensors:

```json

{ "is_open": true,
"message": "Soldering workshop tonight - 8pm to 10pm"
"sensors": [
{
"type": "temperature",
"name": "test_sensor",
"location": "default",
"description": "This is a sensor",
"unit": "°C",
"value": 21.0
},
{
"type": "wind",
"name": "wind_sensor_01",
"location": "The Roof",
"description": "A weather station",
"properties": [
{
"name": "speed",
"unit": "m/s",
"speed": 5.0
},
{
"name": "gust",
"unit": "m/s",
"speed": 9.0
}
]
}
]
}
```
28 changes: 25 additions & 3 deletions memberportal/access/admin.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
from django.contrib import admin
from rest_framework_api_key.admin import APIKeyModelAdmin
from .models import *


@admin.register(AccessControlledDeviceAPIKey)
class AccessControlledDeviceAPIKey(APIKeyModelAdmin):
pass


@admin.register(ExternalAccessControlAPIKey)
class ExternalAccessControlAPIKey(APIKeyModelAdmin):
pass


@admin.register(Doors)
class DoorsAdmin(admin.ModelAdmin):
pass


@admin.register(DoorLog)
class ProfileAdmin(admin.ModelAdmin):
class DoorLogAdmin(admin.ModelAdmin):
pass


@admin.register(Interlock)
class DoorsAdmin(admin.ModelAdmin):
class InterlockAdmin(admin.ModelAdmin):
pass


@admin.register(InterlockLog)
class ProfileAdmin(admin.ModelAdmin):
class InterlockLogAdmin(admin.ModelAdmin):
pass


@admin.register(MemberbucksDevice)
class MemberbucksDeviceAdmin(admin.ModelAdmin):
pass


# TODO:
# @admin.register(MemberbucksDeviceLog)
# class MemberbucksDeviceLogAdmin(admin.ModelAdmin):
# pass
Loading

0 comments on commit ae09772

Please sign in to comment.