Skip to content

Commit

Permalink
Prepare for release of 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beachmachine committed Aug 18, 2022
1 parent 847203f commit 51d0ea1
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.8'
architecture: 'x64'

- name: Install dependencies
Expand Down
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Changelog
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).


## [0.5.0]

### Added
- Added support for ASGI/async

### Removed
- Dropped support for Django 3.1


## [0.4.0]

### Added
- Added support for Django 2.2, 3.1 and 3.2

### Removed
- Dropped support for Django 1.11, 2.0 and 2.1


## [0.3.0]

### Added
- Added support for Django 2.1

### Removed
- Dropped support for Django 1.8, 1.9 and 1.10


## [0.2.1]

### Changed
- Improved `.travis.yml`

### Added
- Added `setup.cfg` with the `license_file` keyword, ensuring that the actual LICENSE file is also installed when
using `pip install`


## [0.2.0]

### Changed
- Behaviour change: Prior to 0.2.0 the UserForeignKey field had `editable` set to `False` only
if `auto_user == True`. Since 0.2.0 `editable` is set to `False`
if `auto_user == True or auto_user_add == True`

### Added
- Added support for Django 2.0


## [0.1.2]

### Added
- Initial Release on PyPi


[0.5.0]: https://github.com/beachmachine/django-userforeignkey/releases/tag/0.5.0
[0.4.0]: https://github.com/beachmachine/django-userforeignkey/releases/tag/0.4.0
[0.3.0]: https://github.com/beachmachine/django-userforeignkey/releases/tag/0.3.0
[0.2.1]: https://github.com/beachmachine/django-userforeignkey/releases/tag/0.2.1
[0.2.0]: https://github.com/beachmachine/django-userforeignkey/releases/tag/0.2.0
[0.1.2]: https://github.com/beachmachine/django-userforeignkey/releases/tag/0.1.2
28 changes: 0 additions & 28 deletions CHANGELOG.rst

This file was deleted.

4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include LICENSE
include README.rst
recursive-include docs *
include README.md
recursive-include docs *
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Django UserForeignKey
=====================

[![PyPI version](https://img.shields.io/pypi/v/django-userforeignkey.svg?maxAge=2592000)](https://pypi.org/project/django-userforeignkey/)
[![Linter and tests](https://github.com/beachmachine/django-userforeignkey/workflows/Module%20tests/badge.svg)](https://github.com/beachmachine/django-userforeignkey/actions)
[![Codecov](https://img.shields.io/codecov/c/gh/beachmachine/django-userforeignkey)](https://codecov.io/gh/beachmachine/django-userforeignkey)

Django UserForeignKey is a simple Django app that will give you a `UserForeignKey` model field for Django models.
This field extends a regular ForeignKey model field, and has the option to automatically set the currently logged in
user on insert and/or update.

Currently, Django 2.2 (Python 3.7+) and Django 3.2 (Python 3.7+) are supported.

If you need support for the insecure and deprecated Python 3.6, please fall back to version 0.4.0.

If you need support for the insecure and deprecated Django 1.11 and/or Python2, please fall back to version 0.3.0.

If you need support for the insecure and deprecated Django 1.8 (and possibly 1.9 and 1.10), please fall back to
version 0.2.1.

There also is a [video tutorial on YouTube](https://www.youtube.com/watch?v=iJCbYMgUDW8>) that shows you basic
functionality of this package.

## Quickstart

1. Install the package from pypi using pip:
```bash
pip install django-userforeignkey
```

2. Add `django_userforeignkey` to your `INSTALLED_APPS` within your Django settings file:
```python
INSTALLED_APPS = [
...
'django_userforeignkey',
]
```

3. Add `django_userforeignkey.middleware.UserForeignKeyMiddleware` to your `MIDDLEWARE` settings like this:

```python
MIDDLEWARE = [
...
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_userforeignkey.middleware.UserForeignKeyMiddleware',
]
```

Make sure to insert the `UserForeignKeyMiddleware` middleware **after** `AuthenticationMiddleware`.

## Example usage

Just add `UserForeignKey` to your model like you would with any other foreign key.


```python
from django.db import models
from django_userforeignkey.models.fields import UserForeignKey

class MyModel(models.Model):
my_data = models.CharField(max_length=64, verbose_name="Very important data that are somehow related to a user")
user = UserForeignKey(auto_user_add=True, verbose_name="The user that is automatically assigned", related_name="mymodels")
```

The `UserForeignKey` behaves just like a normal foreign key to the user model (using `settings.AUTH_USER_MODEL`), and
thus also has properties such as ``related_name``. However, whenever an object is created by calling an authenticated
view (admin, REST API, ...) which contains a ``request.user`` object, the ``request.user`` object is automatically
associated.


## Configuration options

The configuration options are similar to Django's [DateField](https://docs.djangoproject.com/en/4.1/ref/models/fields/#datefield).

* `auto_user`: Automatically sets the current user everytime the object is saved (e.g., created or updated). This is
useful for **last modified by** information.
* `auto_user_add`: Automatically sets the current user when the object is first created. This is useful
for **created by** information.


## Development and tests

```bash
git clone --recursive https://github.com/beachmachine/django-userforeignkey
cd django-userforeignkey
python -m venv ./venv
source venv/bin/activate
pip install -e .
pip install Django
cd tests/user_foreign_key_testapp
python manage.py test
```
122 changes: 0 additions & 122 deletions README.rst

This file was deleted.

5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import find_packages, setup

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
README = readme.read()

# allow setup.py to be run from any path
Expand All @@ -13,12 +13,13 @@
version=os.getenv('PACKAGE_VERSION', '0.0.0').replace('refs/tags/', ''),
packages=find_packages(),
include_package_data=True,
long_description_content_type='text/markdown',
license='BSD License',
description='A simple Django app that will give you a UserForeignKey model field.',
long_description=README,
url='https://github.com/beachmachine/django-userforeignkey/',
author='Andreas Stocker',
author_email='andreas@ks.co.at',
author_email='andreas@stocker.co.it',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
Expand Down

0 comments on commit 51d0ea1

Please sign in to comment.