<commit_before>
from framework import User, get_current_user
from ..model import Node, NodeLog
from ..decorators import must_be_valid_project, must_be_contributor_or_public
from .node import _view_project

def _render_log_contributor(contributor):
    if isinstance(contributor, dict):
        rv = contributor.copy()
        rv.update({'registered' : False})
        return rv
    user = User.load(contributor)
    return {
        'id' : user._primary_key,
        'fullname' : user.fullname,
        'registered' : True,
    }

# todo decorate
def get_log(log_id):

    log = NodeLog.load(log_id)
    user = get_current_user()
    node_to_use = Node.load(log.params.get('node')) or Node.load(log.params.get('project'))

    if not node_to_use.is_public and not node_to_use.is_contributor(user):
        return {
            'status' : 'failure',
        }

    project = Node.load(log.params.get('project'))
    node = Node.load(log.params.get('node'))

    log_json = {
        'user_id' : log.user._primary_key if log.user else '',
        'user_fullname' : log.user.fullname if log.user else '',
        'api_key' : log.api_key.label if log.api_key else '',
        'project_url' : project.url() if project else '',<commit_msg>send appropriate status codes<commit_after>
from framework import User, get_current_user
from ..model import Node, NodeLog
from ..decorators import must_be_valid_project, must_be_contributor_or_public
from .node import _view_project

from framework import HTTPError
import httplib as http

def _render_log_contributor(contributor):
    if isinstance(contributor, dict):
        rv = contributor.copy()
        rv.update({'registered' : False})
        return rv
    user = User.load(contributor)
    return {
        'id' : user._primary_key,
        'fullname' : user.fullname,
        'registered' : True,
    }

def get_log(log_id):

    log = NodeLog.load(log_id)
    user = get_current_user()
    node_to_use = Node.load(log.params.get('node')) or Node.load(log.params.get('project'))

    if not node_to_use.is_public and not node_to_use.is_contributor(user):
        raise HTTPError(http.FORBIDDEN)

    project = Node.load(log.params.get('project'))
    node = Node.load(log.params.get('node'))

    log_json = {
        'user_id' : log.user._primary_key if log.user else '',
        'user_fullname' : log.user.fullname if log.user else '',
        'api_key' : log.api_key.label if log.api_key else '',
        'project_url' : project.url() if project else '',
{'fraction_non_alphanumeric': 0.11835265893642544, 'fraction_numerical': 0.0, 'mean_word_length': 3.190954773869347, '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': '6317622', 'n_tokens_mistral': 825, 'n_tokens_neox': 806, 'n_words': 180}