예제 #1
0
from django.contrib.auth.models import User, Group
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import PermissionDenied
from django.db import models
from django.db.models import options, ForeignKey, JSONField
from django.utils import timezone
from django.utils.text import slugify as __slugify

from guardian.shortcuts import assign_perm

from seqr.utils.logging_utils import log_model_update, log_model_bulk_update, SeqrLogger
from seqr.utils.xpos_utils import get_chrom_pos
from reference_data.models import GENOME_VERSION_GRCh37, GENOME_VERSION_CHOICES
from settings import MME_DEFAULT_CONTACT_NAME, MME_DEFAULT_CONTACT_HREF, MME_DEFAULT_CONTACT_INSTITUTION

logger = SeqrLogger(__name__)

#  Allow adding the custom json_fields and internal_json_fields to the model Meta
# (from https://stackoverflow.com/questions/1088431/adding-attributes-into-django-models-meta-class)
options.DEFAULT_NAMES = options.DEFAULT_NAMES + (
    'json_fields',
    'internal_json_fields',
)

CAN_VIEW = 'can_view'
CAN_EDIT = 'can_edit'


def _slugify(text):
    # using _ instead of - makes ids easier to select, and use without quotes in a wider set of contexts
    return __slugify(text).replace('-', '_')
예제 #2
0
from django.utils.cache import add_never_cache_headers
from django.utils.deprecation import MiddlewareMixin
from django.urls import get_resolver, get_urlconf
import elasticsearch.exceptions
from requests import HTTPError
from social_core.exceptions import AuthException
import json
import traceback

from seqr.utils.elasticsearch.utils import InvalidIndexException, InvalidSearchException
from seqr.utils.logging_utils import SeqrLogger
from seqr.views.utils.json_utils import create_json_response
from seqr.views.utils.terra_api_utils import TerraAPIException
from settings import DEBUG, LOGIN_URL

logger = SeqrLogger()

EXCEPTION_ERROR_MAP = {
    PermissionDenied:
    403,
    ObjectDoesNotExist:
    404,
    Http404:
    404,
    InvalidIndexException:
    400,
    InvalidSearchException:
    400,
    AuthException:
    401,
    elasticsearch.exceptions.ConnectionError: