<commit_before>"""
For CommonsCloud copyright information please see the LICENSE document
(the "License") included with this software package. This file may not
be used in any manner except in compliance with the License

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""


"""
Import Python Dependencies
"""
import ast
import boto
import json
import os.path
import uuid

from datetime import datetime
from uuid import uuid4

from functools import wraps

"""
Import Flask Dependencies
"""
from werkzeug import secure_filename

from flask import abort
from flask import request
from flask import current_app

from flask.ext.restless.views import API
from flask.ext.restless.views import FunctionAPI
from flask.ext.restless.search import search


"""
Import Commons Cloud Dependencies
"""
from CommonsCloudAPI.models.base import CommonsModel

from CommonsCloudAPI.models.template import Template
from CommonsCloudAPI.models.field import Field
from CommonsCloudAPI.models.statistic import Statistic

from CommonsCloudAPI.extensions import db
from CommonsCloudAPI.extensions import logger
from CommonsCloudAPI.extensions import oauth
from CommonsCloudAPI.extensions import sanitize
from CommonsCloudAPI.extensions import status as status_

from CommonsCloudAPI.utilities.geometry import ST_GeomFromGeoJSON

from CommonsCloudAPI.signals import trigger_feature_created

from geoalchemy2.elements import WKBElement
import geoalchemy2.functions as geofunc


"""
is_public allows us to check if feature collections are supposed to public, if
they are, then we don't need to check for OAuth crednetials to allow access
"""
class is_public(object):

    def __init__(self):
      pass

    def __call__(self, f):
        @wraps(f)
        def decorated_function(*args, **kwargs):

          storage = self.validate_storage(kwargs['storage'])

          this_template = Template.query.filter_by(storage=storage).first()

          keywords = kwargs

          if not this_template.is_public:
            keywords['is_public'] = False
          else:
            keywords['is_public'] = True

          return f(*args, **keywords)
     
        return decorated_function

    """
    Storage name
    """
    def validate_storage(self, storage_name):

      if not storage_name.startswith('type_'):
        storage_name = str('type_' + storage_name)

      return storage_name

class is_crowdsourced(object):

    def __init__(self):
      pass

    def __call__(self, f):
        @wraps(f)
        def decorated_function(*args, **kwargs):

          storage = self.validate_storage(kwargs['storage'])

          this_template = Template.query.filter_by(storage=storage).first()

          keywords = kwargs

          if not this_template.is_crowdsourced:
            keywords['is_crowdsourced'] = False
          else:
            keywords['is_crowdsourced'] = True

          return f(*args, **keywords)
     
        return decorated_function

    """
    Storage name
    """
    def validate_storage(self, storage_name):

      if not storage_name.startswith('type_'):
        storage_name = str('type_' + storage_name)

      return storage_name


"""
Define our individual models
"""
class Feature(CommonsModel):

    __public__ = ['id', 'created', 'status', 'geometry']

    def __init__(self):
      pass

    def feature_create(self, request_object, storage_):
<commit_msg>Added updated to the list of features default public fields;<commit_after>"""
For CommonsCloud copyright information please see the LICENSE document
(the "License") included with this software package. This file may not
be used in any manner except in compliance with the License

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""


"""
Import Python Dependencies
"""
import ast
import boto
import json
import os.path
import uuid

from datetime import datetime
from uuid import uuid4

from functools import wraps

"""
Import Flask Dependencies
"""
from werkzeug import secure_filename

from flask import abort
from flask import request
from flask import current_app

from flask.ext.restless.views import API
from flask.ext.restless.views import FunctionAPI
from flask.ext.restless.search import search


"""
Import Commons Cloud Dependencies
"""
from CommonsCloudAPI.models.base import CommonsModel

from CommonsCloudAPI.models.template import Template
from CommonsCloudAPI.models.field import Field
from CommonsCloudAPI.models.statistic import Statistic

from CommonsCloudAPI.extensions import db
from CommonsCloudAPI.extensions import logger
from CommonsCloudAPI.extensions import oauth
from CommonsCloudAPI.extensions import sanitize
from CommonsCloudAPI.extensions import status as status_

from CommonsCloudAPI.utilities.geometry import ST_GeomFromGeoJSON

from CommonsCloudAPI.signals import trigger_feature_created

from geoalchemy2.elements import WKBElement
import geoalchemy2.functions as geofunc


"""
is_public allows us to check if feature collections are supposed to public, if
they are, then we don't need to check for OAuth crednetials to allow access
"""
class is_public(object):

    def __init__(self):
      pass

    def __call__(self, f):
        @wraps(f)
        def decorated_function(*args, **kwargs):

          storage = self.validate_storage(kwargs['storage'])

          this_template = Template.query.filter_by(storage=storage).first()

          keywords = kwargs

          if not this_template.is_public:
            keywords['is_public'] = False
          else:
            keywords['is_public'] = True

          return f(*args, **keywords)
     
        return decorated_function

    """
    Storage name
    """
    def validate_storage(self, storage_name):

      if not storage_name.startswith('type_'):
        storage_name = str('type_' + storage_name)

      return storage_name

class is_crowdsourced(object):

    def __init__(self):
      pass

    def __call__(self, f):
        @wraps(f)
        def decorated_function(*args, **kwargs):

          storage = self.validate_storage(kwargs['storage'])

          this_template = Template.query.filter_by(storage=storage).first()

          keywords = kwargs

          if not this_template.is_crowdsourced:
            keywords['is_crowdsourced'] = False
          else:
            keywords['is_crowdsourced'] = True

          return f(*args, **keywords)
     
        return decorated_function

    """
    Storage name
    """
    def validate_storage(self, storage_name):

      if not storage_name.startswith('type_'):
        storage_name = str('type_' + storage_name)

      return storage_name


"""
Define our individual models
"""
class Feature(CommonsModel):

    __public__ = ['id', 'created', 'updated', 'status', 'geometry']

    def __init__(self):
      pass

    def feature_create(self, request_object, storage_):

{'fraction_non_alphanumeric': 0.07295081967213114, 'fraction_numerical': 0.000819672131147541, 'mean_word_length': 3.6131064902331445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '342995', 'n_tokens_mistral': 1978, 'n_tokens_neox': 1878, 'n_words': 662}