<commit_before>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { Link } from 'react-router';
import moment from 'moment';
import classNames from 'classnames/bind';
import BaseLayout from 'containers/BaseLayout';
import Speaker from 'components/Speaker';
import SocialShare from 'components/SocialShare';
import {updateProposal, fetchProposal, fetchProposalServerSideRendering, fetchProposals, fetchTags} from 'actions/proposals';
import NotificationSystem from 'react-notification-system';
import ga from 'react-ga';
import ReactMarkdown from 'react-markdown';
import features, { canUseDom } from 'features';
import TagInput from 'components/react-categorized-tag-input';
import Recommender from 'components/Recommender';
import SessionForm from 'components/SessionForm';
import Attend from 'components/Attend';

import styles from 'css/main';

import defaultSpeakerPic from 'images/default_speaker.png'

const cx = classNames.bind(styles)

class Session extends Component {

    static need = [
      fetchProposal
    ];

    constructor(props) {
      super(props);

      this.state = {
        isEditing: false
      };
    }

    componentWillReceiveProps(newProps) {
      const { dispatch, user, location: { query }, currentProposal } = newProps;

      if (features('voting', false) &&
          currentProposal &&
          !currentProposal.attended &&
          currentProposal.status !== 'archived' &&
          query &&
          query.attend) {
        Attend.attendSession(dispatch, currentProposal.id, user.id, currentProposal.speaker_ids.map(s => s._id), true, 'Login');
      }
    }

    isSpeaker(userId) {
      const { currentProposal: { speaker_ids }, user: { id, authenticated } } = this.props;

      if (authenticated && userId) {
        return userId === id;
      } else if (authenticated && speaker_ids) {
        return speaker_ids.map(speaker => speaker._id).indexOf(id) > -1;
      } else {
        return false;
      }
    }

    previewSession() {
      const { currentProposal: { outline, title, abstract, type, attended, tags, speaker_ids, status, hall, startTime, endTime, slides_gdrive_id, video_url }, user: { id, authenticated, isReversimTeamMember }, location } = this.props;

      let proposalType;
      if (type === 'ossil') {
        proposalType = "Open Source in Israel (10 min.)";
      } else if (type === 'lightning') {
        proposalType = "Lightning Talk (5 min.)";
      } else {
        proposalType = "Full Featured (30-40 min.)";
      }

      let action;
      const showEditButton =
        isReversimTeamMember ||
        features('editAcceptedProposals', false) && this.isSpeaker() && status === 'accepted' ||
        features('submission', false) && this.isSpeaker();

      if (showEditButton) {
        action = <div className={cx("row", "pull-right")} style={{margin: '50px 0'}}><a href="#" onClick={this.toggleEdit.bind(this)} className={cx('btn', 'btn-outline-clr', 'btn-sm')}>Edit</a></div>
      }

      let proposalTags;
      if (features('tagging', false) && tags && tags.length > 0) {
        proposalTags = <p><small className={cx("text-alt")}>{tags.map((tag, index) => <span className={cx('session-tag')} key={index}>#{tag}</span>)}</small></p>
      }

      let speakerTrackRecord;
      if (isReversimTeamMember) {
        speakerTrackRecord =
          <div style={{marginTop: 30}}>
            <h6>Speaker{speaker_ids && speaker_ids.length > 1 ? 's' : undefined} Track Record</h6>
            {speaker_ids && speaker_ids.map((speaker, i) => <ReactMarkdown key={i} source={speaker.trackRecord || ''} className={cx("markdown-block")} />)}
          </div>
      }

      console.log("outline", outline);
      let sessionOutline = isReversimTeamMember && outline && (
        <div style={{marginTop: 30}}>
          <h6>Session outline</h6>
          <ReactMarkdown source={outline.replace(/\n/g, '<br/>')} className={cx("markdown-block")}/>
        </div>
      );

      let video = isReversimTeamMember && (
        <div style={{marginTop: 30}}><commit_msg>split track record into lines<commit_after>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { Link } from 'react-router';
import moment from 'moment';
import classNames from 'classnames/bind';
import BaseLayout from 'containers/BaseLayout';
import Speaker from 'components/Speaker';
import SocialShare from 'components/SocialShare';
import {updateProposal, fetchProposal, fetchProposalServerSideRendering, fetchProposals, fetchTags} from 'actions/proposals';
import NotificationSystem from 'react-notification-system';
import ga from 'react-ga';
import ReactMarkdown from 'react-markdown';
import features, { canUseDom } from 'features';
import TagInput from 'components/react-categorized-tag-input';
import Recommender from 'components/Recommender';
import SessionForm from 'components/SessionForm';
import Attend from 'components/Attend';

import styles from 'css/main';

import defaultSpeakerPic from 'images/default_speaker.png'

const cx = classNames.bind(styles)

class Session extends Component {

    static need = [
      fetchProposal
    ];

    constructor(props) {
      super(props);

      this.state = {
        isEditing: false
      };
    }

    componentWillReceiveProps(newProps) {
      const { dispatch, user, location: { query }, currentProposal } = newProps;

      if (features('voting', false) &&
          currentProposal &&
          !currentProposal.attended &&
          currentProposal.status !== 'archived' &&
          query &&
          query.attend) {
        Attend.attendSession(dispatch, currentProposal.id, user.id, currentProposal.speaker_ids.map(s => s._id), true, 'Login');
      }
    }

    isSpeaker(userId) {
      const { currentProposal: { speaker_ids }, user: { id, authenticated } } = this.props;

      if (authenticated && userId) {
        return userId === id;
      } else if (authenticated && speaker_ids) {
        return speaker_ids.map(speaker => speaker._id).indexOf(id) > -1;
      } else {
        return false;
      }
    }

    previewSession() {
      const { currentProposal: { outline, title, abstract, type, attended, tags, speaker_ids, status, hall, startTime, endTime, slides_gdrive_id, video_url }, user: { id, authenticated, isReversimTeamMember }, location } = this.props;

      let proposalType;
      if (type === 'ossil') {
        proposalType = "Open Source in Israel (10 min.)";
      } else if (type === 'lightning') {
        proposalType = "Lightning Talk (5 min.)";
      } else {
        proposalType = "Full Featured (30-40 min.)";
      }

      let action;
      const showEditButton =
        isReversimTeamMember ||
        features('editAcceptedProposals', false) && this.isSpeaker() && status === 'accepted' ||
        features('submission', false) && this.isSpeaker();

      if (showEditButton) {
        action = <div className={cx("row", "pull-right")} style={{margin: '50px 0'}}><a href="#" onClick={this.toggleEdit.bind(this)} className={cx('btn', 'btn-outline-clr', 'btn-sm')}>Edit</a></div>
      }

      let proposalTags;
      if (features('tagging', false) && tags && tags.length > 0) {
        proposalTags = <p><small className={cx("text-alt")}>{tags.map((tag, index) => <span className={cx('session-tag')} key={index}>#{tag}</span>)}</small></p>
      }

      let speakerTrackRecord;
      if (isReversimTeamMember) {
        speakerTrackRecord =
          <div style={{marginTop: 30}}>
            <h6>Speaker{speaker_ids && speaker_ids.length > 1 ? 's' : undefined} Track Record</h6>
            {speaker_ids && speaker_ids.map((speaker, i) => <ReactMarkdown key={i} source={speaker.trackRecord && speaker.trackRecord.replace(/\n/g, '<br/>') || ''} className={cx("markdown-block")} />)}
          </div>
      }

      console.log("outline", outline);
      let sessionOutline = isReversimTeamMember && outline && (
        <div style={{marginTop: 30}}>
          <h6>Session outline</h6>
          <ReactMarkdown source={outline.replace(/\n/g, '<br/>')} className={cx("markdown-block")}/>
        </div>
      );

      let video = isReversimTeamMember && (
        <div style={{marginTop: 30}}>
{'fraction_non_alphanumeric': 0.14642043410480873, 'fraction_numerical': 0.0055162489507135145, 'mean_word_length': 3.2551020408163267, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 62, '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': '3189142', 'n_tokens_mistral': 2521, 'n_tokens_neox': 2478, 'n_words': 579}