<commit_before># -*- coding: utf-8 -*-
import logging
import httplib as http

from flask import request
from modularodm import Q
from modularodm.exceptions import ModularOdmException

from framework import status
from framework.utils import iso8601format
from framework.mongo import StoredObject
from framework.auth.decorators import must_be_logged_in, collect_auth
from framework.exceptions import HTTPError, PermissionsError
from framework.mongo.utils import from_mongo

from website import language

from website.exceptions import NodeStateError
from website.project import clean_template_name, new_node, new_private_link
from website.project.decorators import (
    must_be_contributor_or_public,
    must_be_valid_project,
    must_have_permission,
    must_not_be_registration,
)
from website.project.model import has_anonymous_link, resolve_pointer
from website.project.forms import NewNodeForm
from website.models import Node, Pointer, WatchConfig, PrivateLink
from website import settings
from website.views import _render_nodes
from website.profile import utils
from website.project import new_folder
from website.util.sanitize import strip_html


logger = logging.getLogger(__name__)


@must_be_valid_project  # returns project
@must_have_permission('write')
@must_not_be_registration
def edit_node(auth, **kwargs):
    node = kwargs['node'] or kwargs['project']
    post_data = request.json
    edited_field = post_data.get('name')
    value = strip_html(post_data.get('value', ''))
    if edited_field == 'title':
        node.set_title(value, auth=auth)
    elif edited_field == 'description':
        node.set_description(value, auth=auth)
    node.save()
    return {'status': 'success'}


##############################################################################
# New Project
##############################################################################


@must_be_logged_in
def project_new(**kwargs):
    return {}


@must_be_logged_in
def project_new_post(auth, **kwargs):
    user = auth.user

    title = strip_html(request.json.get('title'))
    template = request.json.get('template')
    description = strip_html(request.json.get('description'))
<commit_msg>Disallow blank project names It is now not possible to make a project with whitespace. It was a one-line change: title = title.strip()<commit_after># -*- coding: utf-8 -*-
import logging
import httplib as http

from flask import request
from modularodm import Q
from modularodm.exceptions import ModularOdmException

from framework import status
from framework.utils import iso8601format
from framework.mongo import StoredObject
from framework.auth.decorators import must_be_logged_in, collect_auth
from framework.exceptions import HTTPError, PermissionsError
from framework.mongo.utils import from_mongo

from website import language

from website.exceptions import NodeStateError
from website.project import clean_template_name, new_node, new_private_link
from website.project.decorators import (
    must_be_contributor_or_public,
    must_be_valid_project,
    must_have_permission,
    must_not_be_registration,
)
from website.project.model import has_anonymous_link, resolve_pointer
from website.project.forms import NewNodeForm
from website.models import Node, Pointer, WatchConfig, PrivateLink
from website import settings
from website.views import _render_nodes
from website.profile import utils
from website.project import new_folder
from website.util.sanitize import strip_html


logger = logging.getLogger(__name__)


@must_be_valid_project  # returns project
@must_have_permission('write')
@must_not_be_registration
def edit_node(auth, **kwargs):
    node = kwargs['node'] or kwargs['project']
    post_data = request.json
    edited_field = post_data.get('name')
    value = strip_html(post_data.get('value', ''))
    if edited_field == 'title':
        node.set_title(value, auth=auth)
    elif edited_field == 'description':
        node.set_description(value, auth=auth)
    node.save()
    return {'status': 'success'}


##############################################################################
# New Project
##############################################################################


@must_be_logged_in
def project_new(**kwargs):
    return {}


@must_be_logged_in
def project_new_post(auth, **kwargs):
    user = auth.user

    title = strip_html(request.json.get('title'))
    template = request.json.get('template')
    description = strip_html(request.json.get('description'))
    title = title.strip()

{'fraction_non_alphanumeric': 0.14519337016574585, 'fraction_numerical': 0.0022099447513812156, 'mean_word_length': 5.755223880597015, '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': '2949838', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1231, 'n_words': 335}