Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from pygraz/21-upgrade-to-django-2
Browse files Browse the repository at this point in the history
#21 Upgrade to django 2
  • Loading branch information
roskakori authored Dec 5, 2022
2 parents 2bd9063 + b94fac1 commit 902a35b
Show file tree
Hide file tree
Showing 127 changed files with 9,260 additions and 2,483 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source = pygraz_website
branch = True

[report]
omit = *tests*,*migrations*,*settings*,*wsgi*
omit = *tests*,*migrations*,*settings*,*wsgi*
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
service_name: travis-ci
service_name: travis-ci
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
# TODO#34: Clean up flake8 issue.
ignore = E203,E722,F401,F403,F811,F821,F841,W503
max-line-length = 120
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Procfile
.tox
.coverage
htmlcov
/database.db
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/pygraz_website.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
exclude: "^.idea"

repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort

- repo: https://github.com/ambv/black
rev: 22.10.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: check-added-large-files
- id: check-ast
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: ["pep8-naming==0.12.1"]

# NOTE: This should be the last check to ensure everything else is checked
# even for the rare case a commit should go into one of the protected
# branches.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: no-commit-to-branch
args: ["--branch", "develop"]
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore Django templates which otherwise prettier would destroy by inserting
# syntactically invalid new lines.
*.html
50 changes: 31 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,47 @@ Slides can be linked to from the session page (as well as the meetup page).

## Requirements

* Django and everything mentioned in the requirements.txt
* Compass
* For all functionality: a [Postmark][pm] account
* For all functionality: a [Recaptcha][rc] account
- Django and everything mentioned in the requirements.txt
- Compass
- For all functionality: a [Postmark][pm] account
- For all functionality: a [Recaptcha][rc] account

To install the Python requirements, using [pip][pip] is recommended.

## Setup

First clone this repository:
<pre>

```bash
git clone <url of this repo>
cd website
</pre>
```

Then create a virtualenv for all the Python requirements, activate it and install the requirements:
<pre>

```bash
mkvirtualenv --no-site-packages env
source env/bin/active
pip install -r requirements.txt
</pre>
pip install -r requirements/base.txt
pip install -r requirements/development.txt
```

We are using a multi-settings-file approach for handling settings on different target systems. For local development
you should use "pygraz_website/settings/development.py" which just sets some plain defaults and doesn't send emails.

Now on to creating the database. By default the website looks for a PostgreSQL database by the name of "pygraz-website"
accessibly by the current system user.
Next, install the pre-commit hooks to perform static checks on your code everytime you commit:

```bash
pre-commit install
```

Now on to creating the database. By default, the website looks for a PostgreSQL database by the name of
"pygraz-website" accessibly by the current system user.

If you want to use for instance a sqlite database, add following content to your development.py file you created in
the last step:

<pre><code>
```python
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
Expand All @@ -52,24 +61,28 @@ DATABASES = {
'PORT': '',
}
}
</code></pre>
```

Now run following commands to initialize the database:

<pre>
```bash
python manage-dev.py syncdb
python manage-dev.py migrate
</pre>
```

To finally start the server run ...

<pre>python manage-dev.py runserver</pre>
```bash
python manage-dev.py runserver
```

When you first visit http://localhost:8000, you will notice that all the stylesheets are still missing.
For local development we would recommend that you open another terminal, go to the pygraz_website/static folder and
execute following command:

<pre>compass watch</pre>
```bash
compass watch
```

This will compile the stylesheets using Compass and keep the process running so that changes the the .scss files are
automatically compiled into .css files.
Expand All @@ -84,12 +97,11 @@ bundle it with the website's source code. For details on this font visit http://
For deployments we are using an Ansible playbook which builds a production.zip
and deploys that onto the target server:

```
```bash
cd ansible/playbooks
ansible-playbook -i ../hosts deploy.yml
```


[pip]: http://pypi.python.org/pypi/pip
[rc]: http://recaptcha.net/
[pm]: http://postmarkapp.com
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.8"
services:
postgres:
container_name: "pygraz_postgres"
image: "postgres:14"
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "5433:5432"
environment:
POSTGRES_USERNAME: "postgres"
POSTGRES_PASSWORD: "deMo.123"

volumes:
postgres-data:
driver: local
2 changes: 1 addition & 1 deletion production-exclude.lst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
.codeintel
*.DS_Store
*.zip
*.lst
*.lst
10 changes: 6 additions & 4 deletions pygraz_website/apps/accounts/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Registry(object):
The content registry represents an index of all the model classes that
are relevant for user content.
"""

_idx = []

def register(self, proxy):
Expand All @@ -25,16 +26,16 @@ class BaseProxy(object):
Every content provider has to register a so-called contentproxy which
should extend this base class.
"""

_has_content = None
label = "Meine Daten"
model_class = None

def __init__(self, request, user):
self.request = request
self.user = user
if not hasattr(self, 'items_template') or self.item_template is None:
self.items_template = 'accounts/contents/{0}_items.html'.format(
self.model_class.__name__.lower())
if not hasattr(self, "items_template") or self.item_template is None:
self.items_template = "accounts/contents/{0}_items.html".format(self.model_class.__name__.lower())

def get_queryset(self):
return []
Expand All @@ -47,13 +48,14 @@ def has_content(self):

@property
def items(self):
if not hasattr(self, '_items') or self._items is None:
if not hasattr(self, "_items") or self._items is None:
self._items = self.get_queryset()
return self._items


REGISTRY = Registry()


def register(proxy):
REGISTRY.register(proxy)

Expand Down
Loading

0 comments on commit 902a35b

Please sign in to comment.