Commit a354e0ff authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

initial

parent ca7540a1
Pipeline #36 canceled with stages
{
"python.pythonPath": "/home/nestorid/.pyenv/versions/reqman/bin/python"
}
\ No newline at end of file
# Created by https://www.gitignore.io/api/vim,osx,emacs,linux,macos,django,python,windows,pycharm,virtualenv,sublimetext,visualstudiocode
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
media
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
### Linux ###
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### OSX ###
# General
# Icon must end with two \r
# Thumbnails
# Files that might appear in the root of a volume
# Directories potentially created on remote AFP share
### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Python ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
develop-eggs/
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
# Django stuff:
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# 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/
.dmypy.json
dmypy.json
### Python Patch ###
.venv/
### Python.VirtualEnv Stack ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json
### SublimeText ###
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
### VirtualEnv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/vim,osx,emacs,linux,macos,django,python,windows,pycharm,virtualenv,sublimetext,visualstudiocode
# reqman
`api` — backend application
`build` — build scripts, docker/docker-compose
### How to run
#### Development mode
`docker-compose -f build/docker-compose-dev.yml up`
will run only services needed for development like PostgreSQL, Redis etc
`docker-compose -f build/docker-compose-api.yml up`
will run all needed services and API (backend application)
\ No newline at end of file
PROJECTNAME=$(notdir $(shell pwd))
run:
python manage.py runserver_plus
test:
pytest -s -l --verbose --strict --pylava ${PROJECTNAME}
migrate:
python manage.py migrate
req-compile:
@for fl in $(shell ls requirements/); do pip-compile requirements/$${fl}; done
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "reqman.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
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?"
) from exc
execute_from_command_line(sys.argv)
[pylama]
format = pycodestyle
skip = */.tox/*,*/.env/*,*/migrations/*
linters = pycodestyle,pyflakes,mccabe
[pylama:pycodestyle]
max_line_length = 120
[pylama:pylint]
max_line_length = 120
load-plugins = pylint_django
\ No newline at end of file
[tool.black]
include = '\.pyi?$'
line-length = 120
exclude = '''
(
/(
\.git
|\.tox
|migrations
)/
)
'''
[pytest]
markers =
bandit
bandit_targets = reqman
bandit_recurse = true
DJANGO_SETTINGS_MODULE = reqman.settings
# -- recommended but optional:
python_files = tests.py test_*.py *_test
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from django.utils.translation import gettext_lazy as _
from . import models
from . import forms
@admin.register(models.User)
class UserAdmin(DjangoUserAdmin):
fieldsets = (
(None, {"fields": ("password",)}),
(_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
(_("Permissions"), {"fields": ("is_active", "is_staff", "is_superuser", "groups", "user_permissions")}),
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
)
add_fieldsets = ((None, {"classes": ("wide",), "fields": ("email", "password1", "password2")}),)
list_display = ("email", "first_name", "last_name", "is_staff")
search_fields = ("first_name", "last_name", "email")
ordering = ("email",)
form = forms.AdminUserChangeForm
from django.apps import AppConfig
class AccountConfig(AppConfig):
name = "reqman.apps.account"
from django.contrib.auth import forms
from . import models
class AdminUserChangeForm(forms.UserChangeForm):
class Meta:
model = models.User
fields = "__all__"
from django.contrib.auth.models import BaseUserManager
from reqman.apps.common import models as core_models
class UserManager(core_models.CoreManager, BaseUserManager):
def get_queryset(self):
return core_models.CoreQuerySet(self.model, using=self._db)
def create_user(self, email, password=None):
if not email:
raise ValueError("Users must gave an email address")
user = self.model(email=email)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, password):
user = self.create_user(email, password)
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user
# Generated by Django 2.1.3 on 2018-11-07 09:13
import uuid
from django.db import migrations, models
from django.utils import timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0009_alter_user_last_name_max_length'),
]
operations = [
migrations.CreateModel(
name='User',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='created')),
('updated', models.DateTimeField(auto_now=True, verbose_name='updated')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('email', models.EmailField(max_length=254, unique=True, verbose_name='Email')),
('first_name', models.CharField(blank=True, max_length=30, null=True, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=30, null=True, verbose_name='last name')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=timezone.now, verbose_name='date joined')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'ordering': ('first_name', 'last_name'),
},
),
]
# Generated by Django 2.2.4 on 2020-12-16 10:56
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('account', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='user',
name='date_joined',
field=models.DateTimeField(default=django.utils.timezone.now),
),
]
# Generated by Django 2.2.4 on 2021-01-04 08:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0002_auto_20201216_1056'),
]
operations = [
migrations.AlterField(
model_name='user',
name='email',
field=models.EmailField(max_length=254, unique=True, verbose_name='email'),
),
]
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from reqman.apps.common.models import CoreModel
from . import managers
class User(PermissionsMixin, CoreModel, AbstractBaseUser):
email = models.EmailField(verbose_name=_("email"), unique=True)
first_name = models.CharField(verbose_name=_("first name"), max_length=30, blank=True, null=True)
last_name = models.CharField(verbose_name=_("last name"), max_length=30, blank=True, null=True)
is_staff = models.BooleanField(
_("staff status"), default=False, help_text=_("Designates whether the user can log into this admin site.")
)
is_active = models.BooleanField(
_("active"),
default=True,
help_text=_(
"Designates whether this user should be treated as active. " "Unselect this instead of deleting accounts."
),
)
date_joined = models.DateTimeField(default=timezone.now)
objects = managers.UserManager()
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []
class Meta:
ordering = ("first_name", "last_name")
def __str__(self):
return self.get_full_name() or self.email
def get_short_name(self):
if self.first_name:
return self.first_name
return self.email.split("@")[0]
def get_full_name(self):
return " ".join(filter(None, [self.first_name, self.last_name]))
from django.apps import AppConfig
class CommonConfig(AppConfig):
name = "reqman.apps.common"
import string
from django.core.management.base import BaseCommand
from django.utils.crypto import get_random_string
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("length", type=int)
def handle(self, *args, **options):
print(
get_random_string(
length=options["length"], allowed_chars=string.ascii_letters + string.digits + string.punctuation
)
)
import os
import shutil
from django.conf import settings
from django.core.management.base import CommandError
from django.core.management.commands import startapp
DS_BE_APP_TEMPLATE = "https://be.skeletons.djangostars.com/djangostars_app_template__django{extensions}.tar.gz"
class Command(startapp.Command):
def handle(self, **options):
app_name = options.pop("name")
directory = os.path.join(settings.BASE_DIR, "apps", app_name)
if os.path.exists(directory):
raise CommandError('App with name "{}" already exists'.format(app_name))
os.mkdir(directory)
options["template"] = self.get_template()
options["directory"] = directory
options["project_name"] = settings.ROOT_URLCONF.split(".", 1)[0]
try:
super(Command, self).handle(name=app_name, **options)
except CommandError as ex:
shutil.rmtree(directory)
raise ex
@staticmethod
def get_template():
extensions = []
if "rest_framework" in settings.INSTALLED_APPS:
extensions.append("drf")
return DS_BE_APP_TEMPLATE.format(extensions="_{}".format("_".join(extensions)) if len(extensions) > 0 else "")
from .core import CoreModel, CoreManager, CoreQuerySet
__all__ = ["CoreModel", "CoreManager", "CoreQuerySet"]
from uuid import uuid4
from django.db import models
from django.utils.translation import gettext_lazy as _
class CoreQuerySet(models.QuerySet):
def active(self):
return self.filter(is_active=True)
def inactive(self):
return self.filter(is_active=False)
class CoreManager(models.Manager):
def get_queryset(self):
return CoreQuerySet(self.model, using=self._db)
def active(self):
return self.get_queryset().active()
def inactive(self):
return self.get_queryset().inactive()
class CoreModel(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid4, editable=False)
created = models.DateTimeField(auto_now_add=True, db_index=True, verbose_name=_("created"))
updated = models.DateTimeField(auto_now=True, verbose_name=_("updated"))
is_active = models.BooleanField(default=True, db_index=True)
objects = CoreManager()
class Meta:
abstract = True
def __str__(self):
return str(self.pk)
def __repr__(self):
return f"<{self.__class__.__name__} {self.pk}>"
def activate(self):
if not self.is_active:
self.is_active = True
self.save(update_fields=["is_active", "updated"] if self.pk else None)
def deactivate(self):
if self.is_active:
self.is_active = False
self.save(update_fields=["is_active", "updated"] if self.pk else None)
from rest_framework import permissions
class IsOwnerOrReadOnly(permissions.BasePermission):
"""
Custom permission to only allow owners of an object to edit it.
"""
def has_object_permission(self, request, view, obj):
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
if request.method in permissions.SAFE_METHODS:
return True
# Write permissions are only allowed to the owner of the snippet.
return obj.owner == request.user
\ No newline at end of file
# Created by https://www.gitignore.io/api/vim,osx,emacs,linux,macos,django,python,windows,pycharm,virtualenv,sublimetext,visualstudiocode
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
media
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
### Linux ###
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### OSX ###
# General
# Icon must end with two \r
# Thumbnails
# Files that might appear in the root of a volume
# Directories potentially created on remote AFP share
### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Python ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
develop-eggs/
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
# Django stuff:
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# 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/
.dmypy.json
dmypy.json
### Python Patch ###
.venv/
### Python.VirtualEnv Stack ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json
### SublimeText ###
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
### VirtualEnv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/vim,osx,emacs,linux,macos,django,python,windows,pycharm,virtualenv,sublimetext,visualstudiocode
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ReqtoolConfig(AppConfig):
name = "reqman.apps.reqtool"
from .snippets import Snippet, LANGUAGE_CHOICES, STYLE_CHOICES
\ No newline at end of file
from django.db import models
#from reqman.apps.common.models import CoreModel
from reqman.apps.account.models import User
from pygments.formatters.html import HtmlFormatter
from pygments import highlight
SIMPLE_PREFIX_CHOICES = ( ("",""), ("P1", "If/Unless <logical expression>"), ("P2", "As soon as <occuring functionality>"), ("P3", "As long as <occuring functionality>"))
LOGIC_CONNECTIVE = ( ("",""), ("or","OR"), ("and", "AND"), ("xor", "XOR"))
LOGICAL_EXPRESSION = ( ("",""), ("state value constraint", "state value constraint"), ("occuring functionality", "occuring functionality"))
def create_prefix(instance):
'''Create the Prefix Model for the Boilerplate'''
try :
prefix = Prefix.objects.get(boilerplate = instance, prefix_owner = instance.owner)
if instance.has_prefix:
return
prefix = Prefix.objects.get(boilerplate = instance, prefix_owner = instance.owner)
prefix.delete()
except Prefix.DoesNotExist:
if instance.has_prefix:
prefix = Prefix(boilerplate = instance, prefix_owner = instance.owner)
prefix.save()
def create_main(instance):
'''Create the Main Model for the Boilerplate'''
pass
def create_suffix(instance):
'''Create the Suffix Model for the Boilerplate'''
pass
def create_p1(instance, now_prefix, prev_prefix, series_of_prefix):
try :
prefix = LogicalExpression.objects.get(prefix = instance, prefix_boilerplate = instance.boilerplate, prefix_series = series_of_prefix)
if now_prefix == prev_prefix:
return
prefix = LogicalExpression.objects.get(prefix = instance, prefix_boilerplate = instance.boilerplate, prefix_series = series_of_prefix )
prefix.delete()
if now_prefix == SIMPLE_PREFIX_CHOICES[1][0]:
prefix = LogicalExpression(prefix = instance, prefix_boilerplate = instance.boilerplate, prefix_series = series_of_prefix)
prefix.save()
except LogicalExpression.DoesNotExist:
if now_prefix == SIMPLE_PREFIX_CHOICES[1][0]:
prefix = LogicalExpression(prefix = instance, prefix_boilerplate = instance.boilerplate, prefix_series = series_of_prefix)
prefix.save()
def create_p2(instance, now_prefix, prev_prefix, series_of_prefix):
try :
prefix = OccuringFunctionalityP2.objects.get(prefix_of_occuring_functionality_p2 = instance, prefix_boilerplate_of_occuring_functionality_p2 = instance.boilerplate, prefix_series_of_occuring_functionality_p2 = series_of_prefix)
if now_prefix == prev_prefix:
return
prefix = OccuringFunctionalityP2.objects.get(prefix_of_occuring_functionality_p2 = instance, prefix_boilerplate_of_occuring_functionality_p2 = instance.boilerplate, prefix_series_of_occuring_functionality_p2 = series_of_prefix )
prefix.delete()
if now_prefix == SIMPLE_PREFIX_CHOICES[2][0]:
prefix = OccuringFunctionalityP2(prefix_of_occuring_functionality_p2 = instance, prefix_boilerplate_of_occuring_functionality_p2 = instance.boilerplate, prefix_series_of_occuring_functionality_p2 = series_of_prefix)
prefix.save()
except OccuringFunctionalityP2.DoesNotExist:
if now_prefix == SIMPLE_PREFIX_CHOICES[2][0]:
prefix = OccuringFunctionalityP2(prefix_of_occuring_functionality_p2 = instance, prefix_boilerplate_of_occuring_functionality_p2 = instance.boilerplate, prefix_series_of_occuring_functionality_p2 = series_of_prefix)
prefix.save()
def create_state_value_constraint_from_logical_expression(instance, logical_expression, prev_logical_expression, series_of_log_expr):
try :
log_expr = StateValueConstraint.objects.get(logical_expression = instance, prefix_of_logical_expression = instance.prefix, log_expr_series = series_of_log_expr)
if logical_expression == prev_logical_expression:
return
log_expr = StateValueConstraint.objects.get(logical_expression = instance, prefix_of_logical_expression = instance.prefix, log_expr_series = series_of_log_expr )
log_expr.delete()
if logical_expression == LOGICAL_EXPRESSION[1][0]:
log_expr = StateValueConstraint(logical_expression = instance, prefix_of_logical_expression = instance.prefix, log_expr_series = series_of_log_expr)
log_expr.save()
except StateValueConstraint.DoesNotExist:
if logical_expression == LOGICAL_EXPRESSION[1][0]:
log_expr = StateValueConstraint(logical_expression = instance, prefix_of_logical_expression = instance.prefix, log_expr_series = series_of_log_expr)
log_expr.save()
def create_state_occuring_functionality_from_logical_expression(instance, logical_expression, prev_logical_expression, series_of_log_expr):
try :
log_expr = OccuringFunctionalityForLogicalExpression.objects.get(logical_expression_of_occuring = instance, prefix_of_occuring_for_logical_expression = instance.prefix, log_expres_series = series_of_log_expr)
if logical_expression == prev_logical_expression:
return
log_expr = OccuringFunctionalityForLogicalExpression.objects.get(logical_expression_of_occuring = instance, prefix_of_occuring_for_logical_expression = instance.prefix, log_expres_series = series_of_log_expr )
log_expr.delete()
if logical_expression == LOGICAL_EXPRESSION[2][0]:
log_expr = OccuringFunctionalityForLogicalExpression(logical_expression_of_occuring = instance, prefix_of_occuring_for_logical_expression = instance.prefix, log_expres_series = series_of_log_expr)
log_expr.save()
except OccuringFunctionalityForLogicalExpression.DoesNotExist:
if logical_expression == LOGICAL_EXPRESSION[2][0]:
log_expr = OccuringFunctionalityForLogicalExpression(logical_expression_of_occuring = instance, prefix_of_occuring_for_logical_expression = instance.prefix, log_expres_series = series_of_log_expr)
log_expr.save()
class Boilerplate(models.Model):
owner = models.ForeignKey(User, related_name='boilerplate', on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
has_prefix = models.BooleanField(default=False)
has_main = models.BooleanField(default=False)
has_suffix = models.BooleanField(default=False)
def save(self, **kwargs):
"""Create prefix, main or suffix """
super(Boilerplate, self).save(**kwargs)
create_prefix(self)
class Meta:
ordering = ['created']
class Prefix(models.Model):
#boilerplate = models.OneToOneField(Boilerplate, related_name='prefix', on_delete=models.CASCADE, primary_key=True)
boilerplate = models.ForeignKey(Boilerplate, related_name='prefix', on_delete=models.CASCADE)
prefix_owner = models.ForeignKey(User, related_name='prefix_owner', on_delete=models.CASCADE)
simple_prefix_1 = models.CharField(choices=SIMPLE_PREFIX_CHOICES, max_length=100)
logic_connective_1 = models.CharField(choices=LOGIC_CONNECTIVE, default='', max_length=100, null=True)
simple_prefix_2 = models.CharField(choices=SIMPLE_PREFIX_CHOICES, default='', max_length=100, null=True)
logic_connective_2 = models.CharField(choices=LOGIC_CONNECTIVE, default='', max_length=100, null=True)
simple_prefix_3 = models.CharField(choices=SIMPLE_PREFIX_CHOICES, default='', max_length=100, null=True)
def __init__(self, *args, **kwargs):
super(Prefix, self).__init__(*args, **kwargs)
self.__important_fields = ['simple_prefix_1', 'simple_prefix_2', 'simple_prefix_3']
for field in self.__important_fields:
setattr(self, '__original_%s' % field, getattr(self, field))
def save(self, **kwargs):
"""Create P1, P2 or P3 """
prev_prefix_list = []
super(Prefix, self).save(**kwargs)
for field in self.__important_fields:
orig = '__original_%s' % field
previous_simple_prefix = getattr(self, orig)
prev_prefix_list.append(previous_simple_prefix)
'''Create P1 '''
create_p1( self, self.simple_prefix_1, prev_prefix_list[0], '1')
create_p1( self, self.simple_prefix_2, prev_prefix_list[1], '2')
create_p1( self, self.simple_prefix_3, prev_prefix_list[2], '3')
'''Create P2 '''
create_p2( self, self.simple_prefix_1, prev_prefix_list[0], '1')
create_p2( self, self.simple_prefix_2, prev_prefix_list[1], '2')
create_p2( self, self.simple_prefix_3, prev_prefix_list[2], '3')
class Meta:
ordering = ['boilerplate']
class LogicalExpression(models.Model):
prefix = models.ForeignKey(Prefix, related_name='log_expr', on_delete=models.CASCADE)
prefix_boilerplate = models.ForeignKey(Boilerplate, related_name='logic_expr', on_delete=models.CASCADE)
prefix_series = models.TextField(default='0')
logical_expression_1 = models.CharField(choices=LOGICAL_EXPRESSION , max_length=100)
logic_connective_1 = models.CharField(choices=LOGIC_CONNECTIVE , default='', max_length=100, null=True)
logical_expression_2 = models.CharField(choices=LOGICAL_EXPRESSION , default='', max_length=100, null=True)
logic_connective_2 = models.CharField(choices=LOGIC_CONNECTIVE , default='', max_length=100, null=True)
logical_expression_3 = models.CharField(choices=LOGICAL_EXPRESSION , default='', max_length=100, null=True)
def __init__(self, *args, **kwargs):
super(LogicalExpression, self).__init__(*args, **kwargs)
self.__important_fields = ['logical_expression_1', 'logical_expression_2', 'logical_expression_3', 'prefix_boilerplate']
for field in self.__important_fields:
setattr(self, '__original_%s' % field, getattr(self, field))
def save(self, **kwargs):
"""Create State Value Constraint or Occuring Functionality"""
prev_log_expr_list = []
super(LogicalExpression, self).save(**kwargs)
for field in self.__important_fields:
orig = '__original_%s' % field
previous_log_expr = getattr(self, orig)
prev_log_expr_list.append(previous_log_expr)
'''Create a state value constraint '''
create_state_value_constraint_from_logical_expression( self, self.logical_expression_1, prev_log_expr_list[0], '1')
create_state_value_constraint_from_logical_expression( self, self.logical_expression_2, prev_log_expr_list[1], '2')
create_state_value_constraint_from_logical_expression( self, self.logical_expression_3, prev_log_expr_list[2], '3')
'''Create a occuring functionality '''
create_state_occuring_functionality_from_logical_expression( self, self.logical_expression_1, prev_log_expr_list[0], '1')
create_state_occuring_functionality_from_logical_expression( self, self.logical_expression_2, prev_log_expr_list[1], '2')
create_state_occuring_functionality_from_logical_expression( self, self.logical_expression_3, prev_log_expr_list[2], '3')
class Meta:
ordering = ['prefix_boilerplate']
class OccuringFunctionalityP2(models.Model):
prefix_of_occuring_functionality_p2 = models.ForeignKey(Prefix, related_name='occuring_functionality', on_delete=models.CASCADE)
prefix_boilerplate_of_occuring_functionality_p2 = models.ForeignKey(Boilerplate, related_name='occuring_functionality_b', on_delete=models.CASCADE)
prefix_series_of_occuring_functionality_p2 = models.TextField(default='0')
system_for_occuring_functionality_p2 = models.TextField(max_length=100, blank=True,)
perform_for_occuring_functionality_p2 = models.TextField(max_length=100, blank=True,)
function_for_occuring_functionality_p2 = models.TextField(max_length=100, blank=True,)
item_for_occuring_functionality_p2 = models.TextField(max_length=100, blank=True,)
flow_for_occuring_functionality_p2 = models.TextField(max_length=100, blank=True,)
class Meta:
ordering = ['prefix_boilerplate_of_occuring_functionality_p2']
class StateValueConstraint(models.Model):
prefix_of_logical_expression = models.ForeignKey(Prefix, related_name='prefix_of_log_expr', on_delete=models.CASCADE)
logical_expression = models.ForeignKey(LogicalExpression, related_name='own_log_expr', on_delete=models.CASCADE)
log_expr_series = models.TextField(default='0')
item = models.TextField(max_length=100, blank=True,)
system_state = models.TextField(max_length=100, blank=True,)
state_value = models.TextField(max_length=100, blank=True,)
class Meta:
ordering = ['logical_expression']
class OccuringFunctionalityForLogicalExpression(models.Model):
prefix_of_occuring_for_logical_expression = models.ForeignKey(Prefix, related_name='prefix_of_occur_funct', on_delete=models.CASCADE)
logical_expression_of_occuring = models.ForeignKey(LogicalExpression, related_name='owner_of_log_expr', on_delete=models.CASCADE)
log_expres_series = models.TextField(default='0')
#model to be done (send,receives, ingests etc.)
system_for_logical_expression = models.TextField(max_length=100, blank=True,)
perform_for_logical_expression = models.TextField(max_length=100, blank=True,)
function_for_logical_expression = models.TextField(max_length=100, blank=True,)
item_for_logical_expression = models.TextField(max_length=100, blank=True,)
flow_for_logical_expression = models.TextField(max_length=100, blank=True,)
class Meta:
ordering = ['logical_expression_of_occuring']
\ No newline at end of file
from django.db import models
#from reqman.apps.common.models import CoreModel
from reqman.apps.account.models import User
from pygments.lexers import get_all_lexers
from pygments.styles import get_all_styles
from pygments.lexers import get_lexer_by_name
from pygments.formatters.html import HtmlFormatter
from pygments import highlight
LEXERS = [item for item in get_all_lexers() if item[1]]
LANGUAGE_CHOICES = sorted([(item[1][0], item[0]) for item in LEXERS])
STYLE_CHOICES = sorted([(item, item) for item in get_all_styles()])
class Snippet(models.Model):
owner = models.ForeignKey(User, related_name='snippets', on_delete=models.CASCADE)
highlighted = models.TextField()
created = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=100, blank=True, default='')
code = models.TextField()
linenos = models.BooleanField(default=False)
language = models.CharField(choices=LANGUAGE_CHOICES, default='python', max_length=100)
style = models.CharField(choices=STYLE_CHOICES, default='friendly', max_length=100)
def save(self, *args, **kwargs):
"""Use the `pygments` library to create a highlighted HTML
representation of the code snippet. """
lexer = get_lexer_by_name(self.language)
linenos = 'table' if self.linenos else False
options = {'title': self.title} if self.title else {}
formatter = HtmlFormatter(style=self.style, linenos=linenos,
full=True, **options)
self.highlighted = highlight(self.code, lexer, formatter)
super(Snippet, self).save(*args, **kwargs)
class Meta:
ordering = ['created']
\ No newline at end of file
from .snippets import SnippetSerializer
from .user import UserSerializer
from .requirements import PrefixSerializer
\ No newline at end of file
from rest_framework import serializers
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, LogicalExpression, OccuringFunctionalityP2, StateValueConstraint, OccuringFunctionalityForLogicalExpression
class BoilerplateSerializer(serializers.ModelSerializer):
owner = serializers.ReadOnlyField(source='owner.username')
class Meta:
model = Boilerplate
fields = ('id', 'owner', 'has_prefix', 'has_main', 'has_suffix')
class PrefixSerializer(serializers.ModelSerializer):
boilerplate = serializers.PrimaryKeyRelatedField(read_only=True)
prefix_owner = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = Prefix
fields = ( 'id', 'prefix_owner', 'boilerplate', 'simple_prefix_1', 'logic_connective_1', 'simple_prefix_2', 'logic_connective_2', 'simple_prefix_3')
class LogicalExpressionSerializer(serializers.ModelSerializer):
prefix = serializers.PrimaryKeyRelatedField(read_only=True)
prefix_boilerplate = serializers.PrimaryKeyRelatedField(read_only=True)
prefix_series = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = LogicalExpression
fields = ('id', 'prefix', 'prefix_series', 'prefix_boilerplate', 'logical_expression_1', 'logic_connective_1', 'logical_expression_2', 'logic_connective_2', 'logical_expression_3')
class OccuringFunctionalityP2Serializer(serializers.ModelSerializer):
prefix_of_occuring_functionality_p2 = serializers.PrimaryKeyRelatedField(read_only=True)
prefix_boilerplate_of_occuring_functionality_p2 = serializers.PrimaryKeyRelatedField(read_only=True)
prefix_series_of_occuring_functionality_p2 = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = OccuringFunctionalityP2
fields = ('id', 'prefix_of_occuring_functionality_p2', 'prefix_boilerplate_of_occuring_functionality_p2', 'prefix_series_of_occuring_functionality_p2', 'system_for_occuring_functionality_p2', 'perform_for_occuring_functionality_p2', 'function_for_occuring_functionality_p2', 'item_for_occuring_functionality_p2', 'flow_for_occuring_functionality_p2')
class StateValueConstraintSerializer(serializers.ModelSerializer):
prefix_of_logical_expression = serializers.PrimaryKeyRelatedField(read_only=True)
logical_expression = serializers.PrimaryKeyRelatedField(read_only=True)
log_expr_series = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = StateValueConstraint
fields = ('id', 'prefix_of_logical_expression', 'logical_expression', 'log_expr_series', 'item', 'system_state', 'state_value')
class OccuringFunctionalityForLogicalExpressionSerializer(serializers.ModelSerializer):
prefix_of_occuring_for_logical_expression = serializers.PrimaryKeyRelatedField(read_only=True)
logical_expression_of_occuring = serializers.PrimaryKeyRelatedField(read_only=True)
log_expres_series = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = OccuringFunctionalityForLogicalExpression
fields = ('id', 'prefix_of_occuring_for_logical_expression', 'logical_expression_of_occuring', 'log_expres_series', 'system_for_logical_expression', 'perform_for_logical_expression', 'function_for_logical_expression', 'item_for_logical_expression')
from rest_framework import serializers
from reqman.apps.reqtool.models import Snippet
class SnippetSerializer(serializers.ModelSerializer):
owner = serializers.ReadOnlyField(source='owner.username')
class Meta:
model = Snippet
fields = ('id', 'owner', 'title', 'code', 'linenos', 'language', 'style')
\ No newline at end of file
from rest_framework import serializers
from reqman.apps.account.models import User
from reqman.apps.reqtool.models import Snippet
class UserSerializer(serializers.ModelSerializer):
snippets = serializers.PrimaryKeyRelatedField(many=True, queryset=Snippet.objects.all())
class Meta:
model = User
fields = ['pk', 'first_name', 'last_name', 'email', 'snippets']
\ No newline at end of file
class FusekiActions():
def write(self, data):
print("i am writing form here",data)
\ No newline at end of file
from django.urls import path
from .views import user_views, snippet_views, requirements_views
urlpatterns = [
path('users/', user_views.UserList.as_view(), name='api-user-list'),
path('users/<uuid:pk>/', user_views.UserDetail.as_view(), name='api-post-details'),
#path('snippets/', snippet_views.SnippetListCreateAPIView.as_view(), name='api-snippet-list'),
#path('snippets/<int:pk>/', snippet_views.SnippetDetailsAPIView.as_view(), name='api-snippet-details'),
path('requirements/', requirements_views.BoilerplateListCreateAPIView.as_view(), name='api-requirements-list'),
path('requirements/<int:pk>/', requirements_views.BoilerplateDetailsAPIView.as_view(), name='api-requirements-details'),
#'''Prefix'''
path('requirements/<int:boilerplate>/prefix/', requirements_views.PrefixListCreateAPIView.as_view(), name='api-prefix-list'),
path('requirements/<int:boilerplate>/prefix/<int:pk>/', requirements_views.PrefixDetailsAPIView.as_view(), name='api-prefix-details'),
#'''P1'''
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/', requirements_views.LogicalExpressionListCreateAPIView.as_view(), name='api-log_expr-list'),
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:pk>/', requirements_views.LogicalExpressionDetailsAPIView.as_view(), name='api-log_expr-details'),
#'''P2 or P3'''
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p2/', requirements_views.OccuringFunctionalityP2ListCreateAPIView.as_view(), name='api-occur_func-list'),
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p2/<int:pk>/', requirements_views.OccuringFunctionalityP2DetailsAPIView.as_view(), name='api-occur_func-details'),
#'''Logical expression of P1'''
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/constraint/', requirements_views.StateValueConstraintListCreateAPIView.as_view(), name='api-constraint-list'),
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/constraint/<int:pk>/', requirements_views.StateValueConstraintDetailsAPIView.as_view(), name='api-constraint-details'),
#'''Occuring functionality of P1'''
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/functionality/', requirements_views.OccuringFunctionalityForLogicalExpressionListCreateAPIView.as_view(), name='api-functionality-for-log-list'),
path('requirements/<int:boilerplate>/prefix/<int:prefixs>/p1/<int:log_expr>/functionality/<int:pk>/', requirements_views.OccuringFunctionalityForLogicalExpressionDetailsAPIView.as_view(), name='api-functionality-for-log-list'),
]
\ No newline at end of file
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView
from rest_framework import permissions
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, LogicalExpression, OccuringFunctionalityP2, StateValueConstraint, OccuringFunctionalityForLogicalExpression
from reqman.apps.reqtool.rest_api.serializers.requirements import PrefixSerializer, BoilerplateSerializer, LogicalExpressionSerializer, OccuringFunctionalityP2Serializer,StateValueConstraintSerializer, OccuringFunctionalityForLogicalExpressionSerializer
from reqman.apps.permissions import IsOwnerOrReadOnly
from reqman.apps.reqtool.rest_api.services import fuseki
from django.shortcuts import get_object_or_404
class BoilerplateListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateSerializer
queryset = Boilerplate.objects.all()
#Custom actions when POST
def perform_create(self, serializer):
serializer.save(owner=self.request.user)
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class BoilerplateDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly,
IsOwnerOrReadOnly]
serializer_class = BoilerplateSerializer
queryset = Boilerplate.objects.all()
#Custom actions when PUT
def perform_update(self, serializer):
#print(serializer.validated_data['id'])
#if not Prefix.objects.filter(boilerplate = serializer.validated_data['id']) and (serializer.validated_data['b_prefix'] == True):
# serializer.validated_data['b_prefix'] = True
instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
#print("deleted")
instance.delete()
class PrefixListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = PrefixSerializer
#
queryset = Prefix.objects.all()
def get_queryset(self):
group_pk = self.kwargs['boilerplate']
#print(group_pk)
queryset_prefix = Prefix.objects.filter(boilerplate = group_pk)
return queryset_prefix
#Custom actions when POST
def perform_create(self, serializer):
serializer.save()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = PrefixSerializer
#queryset = Prefix.objects.all()
def get_queryset(self):
group_pk = self.kwargs['boilerplate']
#print(group_pk)
queryset_prefix = Prefix.objects.filter(boilerplate = group_pk)
return queryset_prefix
#Custom actions when PUT
def perform_update(self, serializer):
serializer.save()
#print(self.new.changed_data)
#instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
#print("deleted")
instance.delete()
class LogicalExpressionListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = LogicalExpressionSerializer
#queryset = LogicalExpression.objects.all()
def get_queryset(self):
bp = self.kwargs['boilerplate']
pr = self.kwargs['prefixs']
queryset_prefix = LogicalExpression.objects.filter(prefix_boilerplate = bp, prefix = pr)
return queryset_prefix
#Custom actions when POST
def perform_create(self, serializer):
serializer.save()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class LogicalExpressionDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = LogicalExpressionSerializer
queryset = LogicalExpression.objects.all()
#Custom actions when PUT
def perform_update(self, serializer):
instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
#print("deleted")
instance.delete()
class OccuringFunctionalityP2ListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = OccuringFunctionalityP2Serializer
#queryset = LogicalExpression.objects.all()
def get_queryset(self):
bp = self.kwargs['boilerplate']
pr = self.kwargs['prefixs']
queryset_prefix = OccuringFunctionalityP2.objects.filter(prefix_boilerplate_of_occuring_functionality_p2 = bp, prefix_of_occuring_functionality_p2 = pr)
return queryset_prefix
#Custom actions when POST
def perform_create(self, serializer):
serializer.save()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class OccuringFunctionalityP2DetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = OccuringFunctionalityP2Serializer
queryset = OccuringFunctionalityP2.objects.all()
#Custom actions when PUT
def perform_update(self, serializer):
instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
#print("deleted")
instance.delete()
class StateValueConstraintListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = StateValueConstraintSerializer
#queryset = StateValueConstraint.objects.all()
def get_queryset(self):
le = self.kwargs['log_expr']
pr = self.kwargs['prefixs']
queryset_prefix = StateValueConstraint.objects.filter(logical_expression = le, prefix_of_logical_expression = pr)
return queryset_prefix
#Custom actions when POST
def perform_create(self, serializer):
serializer.save()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class StateValueConstraintDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = StateValueConstraintSerializer
queryset = StateValueConstraint.objects.all()
#Custom actions when PUT
def perform_update(self, serializer):
instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
#print("deleted")
instance.delete()
class OccuringFunctionalityForLogicalExpressionListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = OccuringFunctionalityForLogicalExpressionSerializer
#queryset = StateValueConstraint.objects.all()
def get_queryset(self):
le = self.kwargs['log_expr']
pr = self.kwargs['prefixs']
queryset_prefix = OccuringFunctionalityForLogicalExpression.objects.filter(logical_expression_of_occuring = le, prefix_of_occuring_for_logical_expression = pr)
return queryset_prefix
#Custom actions when POST
def perform_create(self, serializer):
serializer.save()
#print the data of the post
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
class OccuringFunctionalityForLogicalExpressionDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = OccuringFunctionalityForLogicalExpressionSerializer
queryset = OccuringFunctionalityForLogicalExpression.objects.all()
#Custom actions when PUT
def perform_update(self, serializer):
instance = serializer.save()
#write_fuseki = fuseki.FusekiActions()
#write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
#print("deleted")
instance.delete()
\ No newline at end of file
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView
from rest_framework import permissions
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from reqman.apps.reqtool.models import Snippet
from reqman.apps.reqtool.rest_api.serializers import SnippetSerializer
from reqman.apps.permissions import IsOwnerOrReadOnly
from reqman.apps.reqtool.rest_api.services import fuseki
class SnippetListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = SnippetSerializer
queryset = Snippet.objects.all()
#Custom actions when POST
def perform_create(self, serializer):
serializer.save(owner=self.request.user)
#print the data of the post
write_fuseki = fuseki.FusekiActions()
write_fuseki.write(serializer.data)
class SnippetDetailsAPIView(RetrieveUpdateDestroyAPIView):
"""
API view to retrieve, update or delete post
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly,
IsOwnerOrReadOnly]
serializer_class = SnippetSerializer
queryset = Snippet.objects.all()
#Custom actions when PUT
def perform_update(self, serializer):
instance = serializer.save()
write_fuseki = fuseki.FusekiActions()
write_fuseki.write(serializer.data)
#Custom actions when DELETE
def perform_destroy(self, instance):
print("deleted")
instance.delete()
\ No newline at end of file
from rest_framework.generics import ListAPIView, RetrieveAPIView
from reqman.apps.account.models import User
from reqman.apps.reqtool.rest_api.serializers import UserSerializer
class UserList(ListAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
class UserDetail(RetrieveAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
\ No newline at end of file
from django.test import TestCase
from reqman.apps.reqtool.models import Post, Tag
class PostTestCase(TestCase):
def test_post(self):
self.assertEquals(
Post.objects.count(),
0
)
Post.objects.create(
title='active', text='text', is_active=True
)
Post.objects.create(
title='inactive', text='text', is_active=False
)
self.assertEquals(
Post.objects.count(),
2
)
active_posts = Post.objects.active()
self.assertEquals(
active_posts.count(),
1
)
inactive_posts = Post.objects.inactive()
self.assertEquals(
inactive_posts.count(),
1
)
class TagTestCase(TestCase):
def test_tag(self):
self.assertEquals(
Tag.objects.count(),
0
)
Tag.objects.create(name='name')
self.assertEquals(
Tag.objects.count(),
1
)
from django.urls import reverse
from rest_framework.test import APITestCase
from rest_framework.views import status
from reqman.apps.reqtool.models import Post, Tag
class PostListCreateAPIView(APITestCase):
def setUp(self) -> None:
self.url = reverse('api-post-list', kwargs={'version': 'v1'})
def test_create_post(self):
self.assertEquals(
Post.objects.count(),
0
)
data = {
'title': 'title',
'text': 'text'
}
response = self.client.post(self.url, data=data, format='json')
self.assertEquals(response.status_code, status.HTTP_201_CREATED)
self.assertEquals(
Post.objects.count(),
1
)
post = Post.objects.first()
self.assertEquals(
post.title,
data['title']
)
self.assertEquals(
post.text,
data['text']
)
def test_get_post_list(self):
tag = Tag(name='tag_name')
tag.save()
post = Post(title='title1', text='text1')
post.save()
post.tags.add(tag)
response = self.client.get(self.url)
response_json = response.json()
self.assertEquals(
response.status_code,
status.HTTP_200_OK
)
self.assertEquals(
len(response_json),
1
)
data = response_json[0]
self.assertEquals(
data['title'],
post.title
)
self.assertEquals(
data['text'],
post.text
)
self.assertEquals(
data['tags'][0]['name'],
tag.name
)
class PostDetailsAPIViewTest(APITestCase):
def setUp(self) -> None:
self.post = Post(title='title2', text='text2')
self.post.save()
self.url = reverse('api-post-details', kwargs={'version': 'v1', 'pk': self.post.pk})
def test_get_post_details(self):
response = self.client.get(self.url)
self.assertEquals(
response.status_code,
status.HTTP_200_OK
)
data = response.json()
self.assertEquals(
data['pk'],
str(self.post.pk)
)
self.assertEquals(
data['title'],
self.post.title
)
self.assertEquals(
data['text'],
self.post.text
)
def test_update_post(self):
response = self.client.get(self.url)
self.assertEquals(
response.status_code,
status.HTTP_200_OK
)
data = response.json()
data['title'] = 'new_title'
data['text'] = 'new_text'
response = self.client.put(self.url, data=data, format='json')
self.assertEquals(
response.status_code,
status.HTTP_200_OK
)
self.post.refresh_from_db()
self.assertEquals(
self.post.title,
data['title']
)
self.assertEquals(
self.post.text,
data['text']
)
def test_delete_post(self):
self.assertEquals(
Post.objects.count(),
1
)
response = self.client.delete(self.url)
self.assertEquals(
response.status_code,
status.HTTP_204_NO_CONTENT
)
self.assertEquals(
Post.objects.count(),
0
)
from .django import * # noqa
from .contrib import * # noqa
from .reqman import * # noqa
"""
Django settings for reqman project.
Generated by 'django-admin startproject' using Django 2.1.
For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/
"""
import os
from .environment import env
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def rel(*path):
return os.path.join(BASE_DIR, *path)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/checklist/
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("REQMAN_DEBUG")
ALLOWED_HOSTS = env.list("REQMAN_ALLOWED_HOSTS", default=["127.0.0.1", "155.207.131.19"])
SECRET_KEY = env.str("REQMAN_SECRET_KEY")
# Application definition
INSTALLED_APPS = [
# django apps
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# 3rd party apps
"rest_framework",
# our apps
"reqman.apps.common.apps.CommonConfig",
"reqman.apps.account.apps.AccountConfig",
"reqman.apps.reqtool.apps.ReqtoolConfig",
] + env.list("REQMAN_DEV_INSTALLED_APPS", default=[])
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
] + env.list("REQMAN_DEV_MIDDLEWARE", default=[])
ROOT_URLCONF = "reqman.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [rel("templates/")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
]
},
}
]
WSGI_APPLICATION = "reqman.wsgi.application"
# Database
# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#databases
DATABASES = {"default": env.db("REQMAN_DATABASE_URL")}
# Password validation
# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#auth-password-validators
AUTH_USER_MODEL = "account.User"
AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
]
SESSION_COOKIE_SECURE = env.bool("REQMAN_SESSION_COOKIE_SECURE", default=True)
SESSION_COOKIE_NAME = "s"
CSRF_COOKIE_NAME = "c"
# Internationalization
# https://docs.djangoproject.com/en/{{ docs_version }}/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
STATIC_URL = "/static/"
STATIC_ROOT = rel("staticfiles/")
STATICFILES_DIRS = (rel("static/"),)
MEDIA_URL = "/media/"
MEDIA_ROOT = rel("media/")
REST_FRAMEWORK = {
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning'
}
import environ
env = environ.Env(DEBUG=(bool, False))
environ.Env.read_env(".env")
"""reqman URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/{{ docs_version }}/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.conf import settings
from django.urls import path, include, re_path
urlpatterns = [
path("admin/", admin.site.urls),
path('api-auth/', include('reqman.apps.reqtool.rest_api.urls')),
#re_path(r'api/(?P<version>[v1|v2]+)/', include('reqman.apps.reqtool.rest_api.urls')),
#path('api/', include('reqman.apps.reqtool.rest_api.urls'))
]
# enable serve static by django for local development
if settings.DEBUG: # noqa
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
# enable debug_toolbar for local development (if installed)
if settings.DEBUG and "debug_toolbar" in settings.INSTALLED_APPS:
import debug_toolbar
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
"""
WSGI config for reqman project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "reqman.settings")
application = get_wsgi_application()
django
psycopg2-binary
django-environ
gunicorn
djangorestframework
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile /tmp/tmp.be_skeleton_builder/api/requirements/common.in
#
django-environ==0.4.5
django==2.2.4
djangorestframework==3.10.2
gunicorn==19.9.0
psycopg2-binary==2.8.3
pytz==2019.2 # via django
sqlparse==0.3.0 # via django
-r common.in
pip-tools
black
bandit
pytest-django
pytest-cov
pytest-bandit
pytest
pylama
django-extensions
Werkzeug
ipython
ipdb
django-debug-toolbar
\ No newline at end of file
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile /tmp/tmp.be_skeleton_builder/api/requirements/dev.in
#
appdirs==1.4.3 # via black
atomicwrites==1.3.0 # via pytest
attrs==19.1.0 # via black, packaging, pytest
backcall==0.1.0 # via ipython
bandit==1.6.2
black==19.3b0
click==7.0 # via black, pip-tools
coverage==4.5.4 # via pytest-cov
decorator==4.4.0 # via ipython, traitlets
django-debug-toolbar==2.0
django-environ==0.4.5
django-extensions==2.2.1
django==2.2.4
djangorestframework==3.10.2
gitdb2==2.0.5 # via gitpython
gitpython==3.0.2 # via bandit
gunicorn==19.9.0
importlib-metadata==0.19 # via pluggy, pytest
ipdb==0.12.2
ipython-genutils==0.2.0 # via traitlets
ipython==7.7.0
jedi==0.15.1 # via ipython
mccabe==0.6.1 # via pylama
more-itertools==7.2.0 # via pytest, zipp
packaging==19.1 # via pytest
parso==0.5.1 # via jedi
pbr==5.4.2 # via stevedore
pexpect==4.7.0 # via ipython
pickleshare==0.7.5 # via ipython
pip-tools==4.1.0
pluggy==0.12.0 # via pytest
prompt-toolkit==2.0.9 # via ipython
psycopg2-binary==2.8.3
ptyprocess==0.6.0 # via pexpect
py==1.8.0 # via pytest
pycodestyle==2.5.0 # via pylama
pydocstyle==4.0.1 # via pylama
pyflakes==2.1.1 # via pylama
pygments==2.4.2 # via ipython
pylama==7.7.1
pyparsing==2.4.2 # via packaging
pytest-bandit==0.5.2
pytest-cov==2.7.1
pytest-django==3.5.1
pytest==5.1.1
pytz==2019.2 # via django
pyyaml==5.3 # via bandit
six==1.12.0 # via bandit, django-extensions, packaging, pip-tools, prompt-toolkit, stevedore, traitlets
smmap2==2.0.5 # via gitdb2
snowballstemmer==1.9.0 # via pydocstyle
sqlparse==0.3.0 # via django, django-debug-toolbar
stevedore==1.30.1 # via bandit
toml==0.10.0 # via black
traitlets==4.3.2 # via ipython
wcwidth==0.1.7 # via prompt-toolkit, pytest
werkzeug==0.15.5
zipp==0.6.0 # via importlib-metadata
pillow==6.1.0
#Ontologies
rdflib==5.0.0
sparqlwrapper==1.8.5
# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.2.0 # via ipdb, ipython
FROM python:latest
WORKDIR /api
COPY api/ /api/
COPY build/docker-entrypoint-api.sh /api/
RUN ["chmod", "+x", "/api/docker-entrypoint-api.sh"]
RUN ["pip", "install", "-r", "requirements/dev.txt"]
ENTRYPOINT ["/api/docker-entrypoint-api.sh"]
EXPOSE 8000
RUN ["pwd"]
RUN ["ls", "-l"]
CMD ["gunicorn", "reqman.wsgi", "-b", "0.0.0.0:8000"]
\ No newline at end of file
version: 2
jobs:
api:
docker:
- image: circleci/python:stretch-browsers-legacy
- image: circleci/postgres:alpine-postgis-ram
working_directory: ~/app
environment:
- REQMAN_DEBUG=off
- REQMAN_DATABASE_URL=psql://root@localhost:5432/circle_test
- REQMAN_SECRET_KEY=1234567890
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "api/requirements/dev.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install python packages
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -r api/requirements/dev.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "api/requirements/dev.txt" }}
- run:
name: Python version
command: python --version
- run:
name: Codestyle checking by Black
working_directory: api
when: always
command: |
. ../venv/bin/activate
black --check reqman
- run:
name: Run tests
working_directory: api
when: always
command: |
. ../venv/bin/activate
pytest -s -l --verbose --strict \
--pylama \
--bandit \
--junitxml=../tests_artifacts_be/junit/results.xml \
--cov=reqman --cov-report=term --cov-report=html:../tests_artifacts_be/cov_html --cov-report=xml:../tests_artifacts_be/coverage/results.xml \
reqman
- store_test_results:
path: ../tests_artifacts_be
destination: tests_artifacts
- store_artifacts:
path: ../tests_artifacts_be
destination: tests_artifacts
workflows:
version: 2
reqman:
jobs:
- api
version: '3'
services:
api_reqman:
build:
context: ..
dockerfile: build/Dockerfile.api
depends_on:
- postgres
environment:
- REQMAN_DATABASE_URL=psql://reqman:reqman@postgres:5432/reqman
ports:
- "8000:8000"
postgres:
image: postgres:latest
volumes:
- "reqman-pgdata:/var/lib/postgresql/data"
environment:
- POSTGRES_DB=reqman
- POSTGRES_USER=reqman
- POSTGRES_PASSWORD=reqman
ports:
- "5432:5432"
# redis:
# image: redis:latest
# elastic:
# image: elasticsearch:7.2.0
# volumes:
# - "reqman-elasticdata:/usr/share/elasticsearch/data"
# environment:
# - discovery.type=single-node
# ports:
# - "9200:9200"
# - "9300:9200"
volumes:
reqman-pgdata:
reqman-elasticdata:
\ No newline at end of file
version: '3'
services:
postgres:
image: postgres:latest
volumes:
- "reqman-pgdata:/var/lib/postgresql/data"
environment:
- POSTGRES_DB=reqman
- POSTGRES_USER=reqman
- POSTGRES_PASSWORD=reqman
ports:
- "5432:5432"
# redis:
# image: redis:latest
# elastic:
# image: elasticsearch:7.2.0
# volumes:
# - "reqman-elasticdata:/usr/share/elasticsearch/data"
# environment:
# - discovery.type=single-node
# ports:
# - "9200:9200"
# - "9300:9200"
volumes:
reqman-pgdata:
reqman-elasticdata:
\ No newline at end of file
#!/bin/sh
cd /api/
python manage.py migrate
exec "$@"
\ No newline at end of file
build/ci/circle.yml
\ No newline at end of file
d = {}
flag = 1
val = ["","",""]
key = ""
with open("../../../Desktop/foceta-auth/Ontologies/RDO_AOCS/RBO.ttl") as f:
for line in f:
if line.startswith("RBO:"):
key = line
flag = 0
if flag == 0:
if "subClassOf RBO" in line:
val = line.split(':')
elif line.startswith("."):
flag = 1
d[key] = val[2]
print (d)
def subClassOfRbo ():
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment