Skip to content

Commit

Permalink
this is the way
Browse files Browse the repository at this point in the history
  • Loading branch information
pvyParts committed Oct 14, 2020
0 parents commit 4c87ab8
Show file tree
Hide file tree
Showing 26 changed files with 401 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: 2
jobs:
BuildAndTest:
docker:
- image: circleci/python:3.6
steps:
- checkout
- restore_cache:
key: v1-dependency-cache-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
make dev
- run:
name: Run Tests
command: |
python3 -m venv venv
. venv/bin/activate
pip install tox && tox
- store_artifacts:
path: htmlcov/
- save_cache:
key: v1-dependency-cache-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}
paths:
- "venv"
- ".tox"
Deploy:
docker:
- image: circleci/python:3.7
steps:
- checkout
- restore_cache:
key: v1-dependency-cache-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}
- run:
name: install python dependencies
command: |
python3 -m venv venv
. venv/bin/activate
make dev
- run:
name: init .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = $pypi-api-token" >> ~/.pypirc
- run:
name: create packages
command: |
make package
- save_cache:
key: v1-dependency-cache-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}
paths:
- "venv"
- ".tox"
- run:
name: upload to pypi
command: |
. venv/bin/activate
twine upload dist/*
workflows:
version: 2
GroupAssigner:
jobs:
- BuildAndTest
- Deploy:
requires:
- BuildAndTest
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
20 changes: 20 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[run]
branch = True
source = groupassign

omit =
*/groupassign/migrations/*
*/tests/*
*/.tox/*
*/bin/*

[report]
exclude_lines =
if self.debug:
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
def __repr__
raise AssertionError

ignore_errors = True
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include groupassign/templates *
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: help clean dev docs package test

help:
@echo "This project assumes that an active Python virtualenv is present."
@echo "The following make targets are available:"
@echo " dev install all deps for dev environment
@echo " clean remove all old packages
@echo " package create pypi package zip

clean:
rm -rf dist/*

dev:
pip install wheel
pip install -e .
pip install twine

package:
python setup.py sdist
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Group Assigner

Simple plugin for [AllianceAuth](https://gitlab.com/allianceauth/allianceauth) to assign groups to users when they change states.

## Installation
1. `pip install allianceauth-group-assigner`
2. add `'groupassign',` to your `INSTALLED_APPS` in the local.py,
3. run migrations
4. restart auth

## Setup
* Add groups to the required State in admin
* this module will not remove groups
* you can achieve this with the groups state permissions.

## Contributing
Make sure you have signed the [License Agreement](https://developers.eveonline.com/resource/license-agreement) by logging in at https://developers.eveonline.com before submitting any pull requests. All bug fixes or features must not include extra superfluous formatting changes. If you have an issue with formatting, push it in it's own PR for discussion.

## Change log
* v0.0.1
* First release
Empty file added groupassign/__init__.py
Empty file.
Empty file added groupassign/admin.py
Empty file.
Empty file added groupassign/apps.py
Empty file.
Empty file.
Empty file added groupassign/models.py
Empty file.
Empty file added groupassign/signals.py
Empty file.
Empty file added groupassign/tasks.py
Empty file.
23 changes: 23 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
print(os.getcwd())
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv.insert(1, 'test'))
35 changes: 35 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
from setuptools import find_packages, setup

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

os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

install_requires = [
'allianceauth',
]

setup(
name='allianceauth-group-assigner',
version='0.0.1',
packages=find_packages(),
include_package_data=True,
license='GNU General Public License v3 (GPLv3)',
description='Alliance Auth Plugin',
install_requires=install_requires,
long_description=README,
url='https://github.com/pvyParts/allianceauth-group-assigner',
author='ak',
author_email='[email protected]',
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .celery import app as celery_app

__all__ = ['celery_app']
Binary file added tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added tests/__pycache__/celery.cpython-36.pyc
Binary file not shown.
Binary file added tests/__pycache__/test_settings.cpython-36.pyc
Binary file not shown.
Binary file added tests/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added tests/__pycache__/views.cpython-36.pyc
Binary file not shown.
21 changes: 21 additions & 0 deletions tests/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')

from django.conf import settings # noqa

app = Celery('devauth')

# Using a string here means the worker don't have to serialize
# the configuration object to child processes.
app.config_from_object('django.conf:settings')
app.conf.ONCE = {
'backend': 'allianceauth.services.tasks.DjangoBackend',
'settings': {}
}

# Load task modules from all registered Django app configs.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

41 changes: 41 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Alliance Auth Test Suite Django settings.
"""

from allianceauth.project_template.project_name.settings.base import *


# Celery configuration
CELERY_ALWAYS_EAGER = True # Forces celery to run locally for testing

INSTALLED_APPS += [
'groupassign',
]

ROOT_URLCONF = 'tests.urls'

NOSE_ARGS = [
#'--with-coverage',
#'--cover-package=',
#'--exe', # If your tests need this to be found/run, check they py files are not chmodded +x
]

CACHES['default'] = {'BACKEND': 'django.core.cache.backends.db.DatabaseCache'}


PASSWORD_HASHERS = [
'django.contrib.auth.hashers.MD5PasswordHasher',
]

#LOGGING = None # Comment out to enable logging for debugging

# Register an application at https://developers.eveonline.com for Authentication
# & API Access and fill out these settings. Be sure to set the callback URL
# to https://example.com/sso/callback substituting your domain for example.com
# Logging in to auth requires the publicData scope (can be overridden through the
# LOGIN_TOKEN_SCOPES setting). Other apps may require more (see their docs).
ESI_SSO_CLIENT_ID = '123'
ESI_SSO_CLIENT_SECRET = '123'
ESI_SSO_CALLBACK_URL = '123'


14 changes: 14 additions & 0 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.conf.urls import url

import allianceauth.urls
from . import views

urlpatterns = allianceauth.urls.urlpatterns

urlpatterns += [
# Navhelper test urls
url(r'^main-page/$', views.page, name='p1'),
url(r'^main-page/sub-section/$', views.page, name='p1-s1'),
url(r'^second-page/$', views.page, name='p1'),
]

5 changes: 5 additions & 0 deletions tests/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.http import HttpResponse


def page(request):
return HttpResponse('Hello World!')
Loading

0 comments on commit 4c87ab8

Please sign in to comment.