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

Review branding #102

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y curl && curl -LJO https://github.com/P3

# Install NodeJS and bulma css webpack
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends wget && \
wget --no-check-certificate https://deb.nodesource.com/setup_18.x -O /tmp/node.sh && bash /tmp/node.sh && \
wget --no-check-certificate https://deb.nodesource.com/setup_20.x -O /tmp/node.sh && bash /tmp/node.sh && \
apt-get -qq update && apt-get -qq install -y nodejs build-essential

WORKDIR /code
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ dev-dbseed:
@echo "------------------------------------------------------------------"
@docker compose -f docker-compose.dev.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py loaddata qgisfeedproject/qgisfeed/fixtures/*.json


dev-dbrestore:
@echo
@echo "------------------------------------------------------------------"
@echo "Restore dump from /backups/latest-qgisfeed.dmp and /backups/latest-metabase.dmp in production mode"
@echo "------------------------------------------------------------------"
@echo "stopping qgisfeed container"
@docker compose -f docker-compose.dev.yml stop qgisfeed
@echo "Dropping the gis and metabase databases"
-@docker compose -f docker-compose.dev.yml exec postgis su - postgres -c "dropdb --force qgisfeed"
-@docker compose -f docker-compose.dev.yml exec postgis su - postgres -c "dropdb --force metabase"
@echo "Creating the qgisfeed and metabase databases"
-@docker compose -f docker-compose.dev.yml exec postgis su - postgres -c "createdb -O docker -T template1 qgisfeed"
-@docker compose -f docker-compose.dev.yml exec postgis su - postgres -c "createdb -O docker -T template1 metabase"
@echo "Restore database from backups/latest-qgisfeed.dmp and backups/latest-metabase.dmp"
@docker compose -f docker-compose.dev.yml exec postgis su - postgres -c "pg_restore -c /backups/latest-qgisfeed.dmp -d qgisfeed"
@docker compose -f docker-compose.dev.yml exec postgis su - postgres -c "pg_restore -c /backups/latest-metabase.dmp -d metabase"
@echo "Starting qgisfeed container"
@docker compose -f docker-compose.dev.yml up qgisfeed

dev-createsuperuser:
@echo
@echo "------------------------------------------------------------------"
Expand Down
253 changes: 128 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,134 @@

This application is the backend part that manages and serves news for the QGIS welcome page.

![Home Page](img/homepage.webp)


## User guide

<details>
<summary><strong>Home page</strong></summary>
</br>

A home page that displays feeds as they are rendered in QGIS is now available at the root of the web server `/`. Feeds are filterable using the filter widget on the left side. You can directly pass the filter parameters in the url according to the section **Available parameters for filters** in **Endpoint and accepted parameters**

***Note: When calling the root url from QGIS, the response data is in JSON format. See the section Response data for QGIS in the Endpoint and accepted parameters***
</details>

<details>
<summary><strong>Control panel and permissions</strong></summary>
</br>

Users with `staff` flag can enter the control panel at `/admin` and add feed entries, by default entries are not published.

Users with `superadmin` flag will be notified by email when an entry is added to the feed and will be able to publish the entry.

Appart from `superadmin`, only users with the permission `qgisfeed | Can publish QGIS feed` can publish the entry. Like the group `qgisfeedentry_authors`, the group `qgisfeedentry_approver` with the permission `qgisfeed | Can publish QGIS feed` are created when a `Save` signal from the `User` model is detected.

For content field, a hard limit on the number of characters allowed is configurable in administration page (Character limit configurations). If not set, max characters value for this field is 500. If you want to add a custom max characters for this field, the field name value should be `content`.
</details>

<details>
<summary><strong>Manage feeds page</strong></summary>
</br>

***Note: The permissions for this page are the same as described in the Control Panel and permissions.***

After logging in with the login screen at `/accounts/login/` (can be also accessed from the **Login** button on the **Homepage**), users are provided with tools to manage feed items:
- A list of feed items, sortable and filterable by title, date published, author, language, need review
- A button to create a new feed item - clicking will take you to a blank feed item form (See **Feed item form** below)
- Clicking on an item on the list will take you to a feed item form (See **Feed item form** below)

</details>


<details>
<summary><strong>Feed item form</strong></summary>
</br>

The feed item form page is displayed when clicking the **New feed** item button or an item on the list:
- The feed item form is displayed on the left with all the widgets needed to edit the entry. On the right, a preview of the entry as it will be rendered in QGIS. Any edits made in the form shall immediately update the preview.
- In the content widget only the following html tags are allowed: p, strong, italics. A hard limit on the number of characters allowed is configurable in administration page in the model `Character limit configurations`.
- Once a feed item is created or modified, there will be a review step where the user is asked to confirm that they have checked everything carefully.
- The form is placed in the column **Need review** in the list before final submission.
- The form must be approved by someone the permission `qgisfeed | Can publish QGIS feed` before it is published.

</details>

<details>
<summary><strong>Endpoint and accepted parameters</strong></summary>
</br>

### Response data for QGIS
The application has a single endpoint available at the web server root `/` the reponse is in JSON format.

Example call: http://localhost:8000/

Returned data:
```json
[
{
"pk": 1,
"title": "QGIS acquired by ESRI",
"image": "http://localhost:8000/media/feedimages/image.png",
"content": "<p>QGIS is finally part of the ESRI ecosystem, it has been rebranded as CrashGIS to better integrate with ESRI products line.</p>",
"url": "https://www.qgis.com",
"sticky": true,
"publish_from": 1557419128
},
{
"pk": 2,
"title": "Null Island QGIS Meeting",
"image": "",
"content": "<p>Let's dive in the ocean together!</p>",
"url": null,
"sticky": false,
"publish_from": 1557419128
},
{
"pk": 3,
"title": "QGIS Italian Meeting",
"image": "",
"content": "<p>Ciao from Italy!</p>",
"url": null,
"sticky": false,
"publish_from": 1557419128
}
]
```

### Available parameters for filters

The following parameters can be passed by the client to filter available records.

Parameters are validated and in case they are not valid a `Bad Request` HTTP error code `400` is returned.

#### after

When `after` is passed, only the records that have been published after the given value will be returned.

Accepted values: unix timestamp (UTC)

Example call: http://localhost:8000/?after=1557419013


#### lang

When `lang` is passed, the records that have a different `lang` will be excluded from the results. Only the records with `null` `lang` and the records with a matching `lang` will be returned.

Accepted values: `ISO-939-1` two letters language code

Example call: http://localhost:8000/?lang=de

#### lat lon (location)

When `lat` **and** `lon` are passed, the records that have a location filter set will be returned only if the point defined by `lat` and `lon` is within record's location.

Accepted values: `ESPG:4326` latitude and longitude

Example call: http://localhost:8000/?lat=44.5&lon=9.23
</details>

## Installation Guide
<details>
<summary><strong>Development Environment Installation</strong></summary>
Expand Down Expand Up @@ -142,131 +270,6 @@ nginx -s reload

</details>

## User guide

<details>
<summary><strong>Home page</strong></summary>
</br>

A home page that displays feeds as they are rendered in QGIS is now available at the root of the web server `/`. Feeds are filterable using the filter widget on the left side. You can directly pass the filter parameters in the url according to the section **Available parameters for filters** in **Endpoint and accepted parameters**

***Note: When calling the root url from QGIS, the response data is in JSON format. See the section Response data for QGIS in the Endpoint and accepted parameters***
</details>

<details>
<summary><strong>Control panel and permissions</strong></summary>
</br>

Users with `staff` flag can enter the control panel at `/admin` and add feed entries, by default entries are not published.

Users with `superadmin` flag will be notified by email when an entry is added to the feed and will be able to publish the entry.

Appart from `superadmin`, only users with the permission `qgisfeed | Can publish QGIS feed` can publish the entry. Like the group `qgisfeedentry_authors`, the group `qgisfeedentry_approver` with the permission `qgisfeed | Can publish QGIS feed` are created when a `Save` signal from the `User` model is detected.

For content field, a hard limit on the number of characters allowed is configurable in administration page (Character limit configurations). If not set, max characters value for this field is 500. If you want to add a custom max characters for this field, the field name value should be `content`.
</details>

<details>
<summary><strong>Manage feeds page</strong></summary>
</br>

***Note: The permissions for this page are the same as described in the Control Panel and permissions.***

After logging in with the login screen at `/accounts/login/` (can be also accessed from the **Login** button on the **Homepage**), users are provided with tools to manage feed items:
- A list of feed items, sortable and filterable by title, date published, author, language, need review
- A button to create a new feed item - clicking will take you to a blank feed item form (See **Feed item form** below)
- Clicking on an item on the list will take you to a feed item form (See **Feed item form** below)

</details>


<details>
<summary><strong>Feed item form</strong></summary>
</br>

The feed item form page is displayed when clicking the **New feed** item button or an item on the list:
- The feed item form is displayed on the left with all the widgets needed to edit the entry. On the right, a preview of the entry as it will be rendered in QGIS. Any edits made in the form shall immediately update the preview.
- In the content widget only the following html tags are allowed: p, strong, italics. A hard limit on the number of characters allowed is configurable in administration page in the model `Character limit configurations`.
- Once a feed item is created or modified, there will be a review step where the user is asked to confirm that they have checked everything carefully.
- The form is placed in the column **Need review** in the list before final submission.
- The form must be approved by someone the permission `qgisfeed | Can publish QGIS feed` before it is published.

</details>

<details>
<summary><strong>Endpoint and accepted parameters</strong></summary>
</br>

### Response data for QGIS
The application has a single endpoint available at the web server root `/` the reponse is in JSON format.

Example call: http://localhost:8000/

Returned data:
```json
[
{
"pk": 1,
"title": "QGIS acquired by ESRI",
"image": "http://localhost:8000/media/feedimages/image.png",
"content": "<p>QGIS is finally part of the ESRI ecosystem, it has been rebranded as CrashGIS to better integrate with ESRI products line.</p>",
"url": "https://www.qgis.com",
"sticky": true,
"publish_from": 1557419128
},
{
"pk": 2,
"title": "Null Island QGIS Meeting",
"image": "",
"content": "<p>Let's dive in the ocean together!</p>",
"url": null,
"sticky": false,
"publish_from": 1557419128
},
{
"pk": 3,
"title": "QGIS Italian Meeting",
"image": "",
"content": "<p>Ciao from Italy!</p>",
"url": null,
"sticky": false,
"publish_from": 1557419128
}
]
```

### Available parameters for filters

The following parameters can be passed by the client to filter available records.

Parameters are validated and in case they are not valid a `Bad Request` HTTP error code `400` is returned.

#### after

When `after` is passed, only the records that have been published after the given value will be returned.

Accepted values: unix timestamp (UTC)

Example call: http://localhost:8000/?after=1557419013


#### lang

When `lang` is passed, the records that have a different `lang` will be excluded from the results. Only the records with `null` `lang` and the records with a matching `lang` will be returned.

Accepted values: `ISO-939-1` two letters language code

Example call: http://localhost:8000/?lang=de

#### lat lon (location)

When `lat` **and** `lon` are passed, the records that have a location filter set will be returned only if the point defined by `lat` and `lon` is within record's location.

Accepted values: `ESPG:4326` latitude and longitude

Example call: http://localhost:8000/?lat=44.5&lon=9.23
</details>

## Runing tests
<details>
<summary><strong>Run all tests</strong></summary>
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ services:
environment:
POSTGRES_USER: docker
POSTGRES_PASS: docker
POSTGRES_DBNAME: qgisfeed
POSTGRES_DBNAME: qgisfeed
volumes:
- ${QGISFEED_DOCKER_SHARED_VOLUME}:/var/lib/postgresql
- ${QGISFEED_BACKUP_VOLUME}:/backups
# ports:
# - "5436:5432"

Expand Down
Binary file added img/homepage.webp
Binary file not shown.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
"author": "",
"license": "ISC",
"devDependencies": {
"bulma": "^0.9.4",
"css-loader": "^6.8.1",
"highlight.js": "^11.9.0",
"mini-css-extract-plugin": "^2.7.6",
"node-sass": "^9.0.0",
"sass": "^1.77.8",
"sass-loader": "^13.3.2",
"style-loader": "^3.3.3",
"webpack": "^5.89.0",
Expand Down
6 changes: 4 additions & 2 deletions qgisfeedproject/qgisfeed/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ def __init__(self, attrs=None):
if attrs:
default_attrs.update(attrs)
super().__init__(default_attrs)

class Media:
js = ['https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js']
js = ['ol/ol-7.2.2.js']
css = {
'all': ['ol/ol-7.2.2.css']
}

class FeedItemForm(forms.ModelForm):
"""
Expand Down
Binary file added qgisfeedproject/static/images/404.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions qgisfeedproject/static/images/addsupporter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions qgisfeedproject/static/images/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading