-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 29aa534
Showing
23 changed files
with
1,877 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# 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/ | ||
|
||
template | ||
build | ||
.magicindex.json | ||
.noseids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
language: python | ||
python: | ||
- '2.7' | ||
cache: pip | ||
addons: | ||
- mariadb: '10.0' | ||
|
||
env: | ||
- >- | ||
TEST_DATABASE_URL=mysql+mysqldb://root@localhost/geokrety_unittest?charset=utf8mb4 | ||
install: | ||
- pip install -r requirements.dev.txt | ||
|
||
before_script: | ||
- mysql -e 'FLUSH TABLES; DROP DATABASE IF EXISTS geokrety_unittest; CREATE DATABASE geokrety_unittest CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' | ||
script: | ||
- nosetests tests/ -v --with-coverage --with-id --nologcapture --stop | ||
after_success: | ||
- 'bash <(curl -s https://codecov.io/bash)' | ||
- python setup.py sdist | ||
|
||
deploy: | ||
- provider: releases | ||
api_key: | ||
secure: sXLUmqqrcEKel/mHk0g8k0XB7D8PE1Q/8oQkf79jSvoKBfX3+MsUqV6/YlxeO/sCk6SOstn5pNWjr/JsuNv752PaOJs5IAoxsUj2xzWDkoWKoW93NUlzhDfLWi2ITqmmzWwA92fxUkfaok4PPmk1deB0ywmxc8JEXN1PT12kT+ccyVN1R/meqP7auhrqWKVRU5zGpuhIQ8XPp+VRKKJh/odFiTtCFIA0uXRvjHlJLP7OAajMmjEycKGBiJCgIqoe5Ut2rEBAIcmaWy2T23y5o3DBhP4eKIvKXLKAVqLhcsVFgGURTESEMDmdJk3K6EMxY3sdCZBtP3qNHXCsqnfNrJTqf5SiZYr+JwscuoHrAFMZbc4LlC8J3NnbjJane9Co+6pFTK2aWGtxXEKfA8fsgAVDoA3f4J6SH8/HyrZGILeg+MZvUQ613QHViwhjypbvMnHYv6hAWa6ntxDoufZXG3smmwmVtZ5QHZmUXSmZbnNQsBhBHFTtyuvgudzA63LLPCmTu0JvhE/CLTjl2g6ItgKDBVDuCtfDFB9yz2JLAOqPf+t8znfZeh/ft3piWbX4ehJaaKVXnMnVzzs7wJKS+9wZRIbw5NwE8PErkplKqvXJQH6kH1YGUdtb4M7TT/zzXJqFPLXMLwGRfE1qmhhAWHtaftYCJpY2KXL89J+sGHA= | ||
file_glob: true | ||
file: dist/geokrety_api_models-*.tar.gz | ||
skip_cleanup: true | ||
on: | ||
tags: true | ||
repo: geokrety/geokrety-api-models | ||
|
||
- provider: pypi | ||
user: geokrety-bot | ||
password: | ||
secure: D6qjz9fdAbsPAxTU9Q7PBZzSO+821fj1dEQf1yzh8Qk1Ffob82a/JO+gLAgbRJAGZrI4Yo2ii7xMcdW4PU+/si7L0Z6GWTC5qBuRX5YPBj8BrPCngHl300nqhoA9/Cj8/t5NdXmBhN83seK1mM9fytgfQLYeO4YX1p4uE/VgfTehtEcIWpg90nuq3wpMCbQcN5H8fogykyRGHQxBOdcEfiM9jcwdhjH/+rutT4O4oj/In+/rm0DlMkXv7KmzveQwMrKsaZviYfG7qHkEeDeEK4JKQwvixYbnhhdKSfFOcJwtB0mRecgvPD2oth2ZIckPI31tA89T9JHbSK4YGEVAArlvREi4afCJjjt6QoVJnf8zQdaTVy1B3LytEJnTL9ZlVbUTzL/D1maovV9oNHfgJSRufO3Ouk3C0e31fizFmrNYkZ266hseXTbnem1l4Lvg8sGKQbzAPeyx0jPjaPzLFrrugGjzWAdxObTEd0dvnNrhQYX6bUdp646cHMYuqc/n6AZd8Ou49hk+PlIINoxDPHbF4sTcM11HJau8El3rfxbaAucotOruihjvhFl/oqhtM7E0YA94ujhuMCu/niLu892i7B3naWrbUPjcS5+awe6bY951JoOxoc8s/vV8xlz7QWl0FRVjUvbvfT34qEFIu9IVUDYTZc8vxdUAdkh3ZjM= | ||
on: | ||
tags: true | ||
repo: geokrety/geokrety-api-models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 GeoKrety | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[![Python 3](https://pyup.io/repos/github/geokrety/geokrety-api-models/python-3-shield.svg)](https://pyup.io/repos/github/geokrety/geokrety-api-models/) | ||
[![Updates](https://pyup.io/repos/github/geokrety/geokrety-api-models/shield.svg)](https://pyup.io/repos/github/geokrety/geokrety-api-models/) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f9a7080046074fa6b084f14f9bb0a91c)](https://www.codacy.com/app/GeoKrety/geokrety-api-models?utm_source=github.com&utm_medium=referral&utm_content=geokrety/geokrety-api-models&utm_campaign=Badge_Grade) | ||
|
||
|
||
# GeoKrety API Models | ||
|
||
This contains ORM files for the [GeoKrety API project](https://github.com/geokrety/geokrety-api) | ||
or other dependent subprojects such as FAAS functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .badge import Badge | ||
from .geokret import Geokret | ||
from .move import Move | ||
from .move_comment import MoveComment | ||
from .news import News | ||
from .news_comment import NewsComment | ||
from .news_subscription import NewsSubscription | ||
from .user import User | ||
|
||
__all__ = [ | ||
"Badge", | ||
"Geokret", | ||
"Move", | ||
"MoveComment", | ||
"News", | ||
"NewsComment", | ||
"NewsSubscription", | ||
"User", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import datetime | ||
import uuid | ||
|
||
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, event | ||
from sqlalchemy.ext.hybrid import hybrid_property | ||
from sqlalchemy.orm import relationship | ||
|
||
import bleach | ||
import characterentities | ||
|
||
from .base import Base | ||
|
||
|
||
class Badge(Base): | ||
__tablename__ = 'gk-badges-collection' | ||
|
||
id = Column( | ||
'id', | ||
Integer, | ||
primary_key=True, | ||
key='id', | ||
) | ||
|
||
_name = Column( | ||
'name', | ||
String(80), | ||
key='name', | ||
nullable=False, | ||
unique=True, | ||
) | ||
|
||
_description = Column( | ||
'description', | ||
String(128), | ||
key='description', | ||
nullable=True, | ||
) | ||
|
||
filename = Column( | ||
'filename', | ||
String(32), | ||
key='filename', | ||
nullable=False, | ||
) | ||
|
||
created_on_datetime = Column( | ||
'date', | ||
DateTime, | ||
key='created_on_datetime', | ||
nullable=False, | ||
default=datetime.datetime.utcnow, | ||
) | ||
|
||
author_id = Column( | ||
'author_id', | ||
Integer, | ||
ForeignKey('gk-users.id'), | ||
key='author_id', | ||
nullable=False, | ||
) | ||
|
||
author = relationship( | ||
"User", | ||
foreign_keys=[author_id], | ||
backref="created_badges" | ||
) | ||
|
||
@hybrid_property | ||
def name(self): | ||
return characterentities.decode(self._name) | ||
|
||
@name.setter | ||
def name(self, name): | ||
name_clean = bleach.clean(name, strip=True) | ||
self._name = characterentities.decode(name_clean).strip() | ||
|
||
@name.expression | ||
def name(cls): | ||
return cls._name | ||
|
||
@hybrid_property | ||
def description(self): | ||
if self._description is None: | ||
return u'' | ||
return characterentities.decode(self._description) | ||
|
||
@description.setter | ||
def description(self, description): | ||
if description is None: | ||
return u'' | ||
description_clean = bleach.clean(description, strip=True) | ||
self._description = characterentities.decode(description_clean).replace('\x00', '').strip() | ||
|
||
@description.expression | ||
def description(cls): | ||
return cls._description | ||
|
||
@hybrid_property | ||
def upload_url(self): | ||
# Todo send info to other daemon -> redis? | ||
from app.views.minio import storage | ||
res = storage.connection.presigned_put_object( | ||
'badges-incoming', self.filename) # , expires=timedelta(minutes=5)) | ||
return res | ||
# return uuid.uuid4().hex | ||
|
||
|
||
@event.listens_for(Badge, 'init') | ||
def receive_init(target, args, kwargs): | ||
target.filename = uuid.uuid4().hex | ||
|
||
|
||
if __name__ == '__main__': | ||
# Check | ||
badge = Badge() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
Base = declarative_base() |
Oops, something went wrong.