Skip to content

Commit

Permalink
fix some indentation and removes useless stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Dec 13, 2019
1 parent 1b4bcd8 commit 41d7e2c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
5 changes: 3 additions & 2 deletions mosp/bootstrap.py
Expand Up @@ -81,13 +81,16 @@ def datetimeformat(value, format='%Y-%m-%d %H:%M'):
# def instance_domain_name(*args):
# return request.url_root.replace('http', 'https').strip("/")


application.jinja_env.filters['datetimeformat'] = datetimeformat
application.jinja_env.filters['datetime'] = format_datetime
# application.jinja_env.filters['instance_domain_name'] = instance_domain_name

# URL Converters
UUID_RE = re.compile(
r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$')


class UUIDConverter(BaseConverter):
"""
UUID converter for the Werkzeug routing system.
Expand All @@ -96,7 +99,6 @@ def __init__(self, map, strict=True):
super(UUIDConverter, self).__init__(map)
self.strict = strict


def to_python(self, value):
if self.strict and not UUID_RE.match(value):
raise ValidationError()
Expand All @@ -105,7 +107,6 @@ def to_python(self, value):
except ValueError:
raise ValidationError()


def to_url(self, value):
return str(value)

Expand Down
2 changes: 1 addition & 1 deletion mosp/conf.py
Expand Up @@ -5,7 +5,7 @@
This file contain the variables used by the application.
"""
import os
import logging
# import logging

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
PATH = os.path.abspath(".")
Expand Down
4 changes: 2 additions & 2 deletions mosp/models/__init__.py
Expand Up @@ -26,11 +26,11 @@ def uml_graph(db):
import sqlalchemy_schemadisplay as sasd

graph = sasd.create_uml_graph(
mappers(User, Organization, Schema, JsonObject),
mappers(User, Organization, Schema, JsonObject, License),
show_operations=False,
show_multiplicity_one=True
)
graph.write_png('uml_graph.png') # write out the file
graph.write_png('uml_graph.png') # write out the file


def get_or_create(session, model, **kwargs):
Expand Down
24 changes: 12 additions & 12 deletions mosp/web/forms.py
Expand Up @@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-

from urllib.parse import urlparse
from flask import url_for, redirect, request, current_app
from flask import request, current_app
from flask_wtf import FlaskForm
from wtforms import (TextField, TextAreaField, PasswordField, BooleanField,
SelectField, SubmitField, validators, HiddenField,
SelectMultipleField, HiddenField)
SelectMultipleField)
from werkzeug.exceptions import NotFound, HTTPException
from flask_babel import lazy_gettext

Expand Down Expand Up @@ -35,7 +35,6 @@ def __init__(self, *args, **kwargs):
# Any other exceptions
pass


@property
def redirect_target(self):
return self.next.data
Expand All @@ -46,11 +45,11 @@ class SigninForm(RedirectForm):
Sign in form.
"""
login = TextField(lazy_gettext('Login'),
[validators.Length(min=3, max=30),
validators.Required(lazy_gettext('Please enter your login.'))])
[validators.Length(min=3, max=30),
validators.Required(lazy_gettext('Please enter your login.'))])
password = PasswordField(lazy_gettext('Password'),
[validators.Required(lazy_gettext('Please enter your password.')),
validators.Length(min=6, max=100)])
[validators.Required(lazy_gettext('Please enter your password.')),
validators.Length(min=6, max=100)])
submit = SubmitField(lazy_gettext('Log In'))

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -95,11 +94,11 @@ class AddObjectForm(FlaskForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.licenses.choices = [(license.id, license.name) \
self.licenses.choices = [(license.id, license.name)
for license in License.query.all()]
self.refers_to.choices = [(jsonobject.id, jsonobject.name) \
self.refers_to.choices = [(jsonobject.id, jsonobject.name)
for jsonobject in JsonObject.query.all()]
self.referred_to_by.choices = [(jsonobject.id, jsonobject.name) \
self.referred_to_by.choices = [(jsonobject.id, jsonobject.name)
for jsonobject in JsonObject.query.all()]


Expand Down Expand Up @@ -135,9 +134,10 @@ class UserForm(FlaskForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.organizations.choices = [(organization.id, organization.name) \
self.organizations.choices = [(organization.id, organization.name)
for organization in Organization.query.all()]


class OrganizationForm(FlaskForm):
"""
Create or edit an organization (for the administrator).
Expand All @@ -154,7 +154,7 @@ class OrganizationForm(FlaskForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.users.choices = [(user.id, user.login) \
self.users.choices = [(user.id, user.login)
for user in User.query.all()]


Expand Down
2 changes: 1 addition & 1 deletion mosp/web/views/api/v1/organization.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from mosp.bootstrap import application, manager
from mosp.bootstrap import manager

from mosp.models import Organization
from mosp.web.views.api.v1.common import url_prefix
Expand Down
1 change: 0 additions & 1 deletion mosp/web/views/decorators.py
@@ -1,4 +1,3 @@
from sqlalchemy import or_
from functools import wraps
from flask import abort
from flask_login import current_user
Expand Down
4 changes: 2 additions & 2 deletions mosp/web/views/schema.py
Expand Up @@ -7,11 +7,11 @@
from flask_login import login_required, current_user
from flask_babel import gettext
from flask_paginate import Pagination, get_page_args
from sqlalchemy import or_, func, Boolean, Integer, text, desc, nullslast
from sqlalchemy import func, Boolean, Integer, desc, nullslast

from mosp.bootstrap import db
from mosp.web.forms import SchemaForm
from mosp.models import Schema, JsonObject, Organization
from mosp.models import Schema, JsonObject

schema_bp = Blueprint('schema_bp', __name__, url_prefix='/schema')
schemas_bp = Blueprint('schemas_bp', __name__, url_prefix='/schemas')
Expand Down
6 changes: 3 additions & 3 deletions tests/test_user.py
Expand Up @@ -10,8 +10,8 @@ def test_user(session):
session.add(user)
session.commit()

assert user.is_admin == False
assert user.is_api == False
assert user.is_api == False
assert user.is_admin is False
assert user.is_api is False
assert user.is_api is False
assert user.public_profile == True
assert user.check_password('password') == True

0 comments on commit 41d7e2c

Please sign in to comment.