contract Certificates is ERC721Token, Ownable {

  // Token version. Incremented after each workshop manually.
  uint256 internal currentEdition_;

  // Mapping from token ID to edition of the corresponding MLEW workshop
  mapping(uint256 => uint256) internal tokenEditions;

  /**
   * @dev Constructor function
   */
  constructor(string _name, string _symbol) ERC721Token(_name, _symbol) public {
    // Contract starts ready to mint token for the first edition of MLEW
    currentEdition_ = 1;
  }

  /**
   * @dev Gets the edition of the last MLEW workshop.
   * @return uint256 the current edition.
   */
  function currentEdition() public view returns (uint256) {
    return currentEdition_;
  }

  /**
   * @dev Returns the edition of MLEW a given token ID was minted for
   * @dev Throws if the token ID does not exist.
   * @param _tokenId uint256 ID of the token to query
   */
  function tokenEdition(uint256 _tokenId) public view returns (uint256) {
    require(exists(_tokenId));
    return tokenEditions[_tokenId];
  }


  /**
   * @dev Increments the edition, onlyOwner
   */
  function incrementEdition() public onlyOwner() {
    currentEdition_ = currentEdition_ + 1;
  }

  /**
   * @dev Mint a new token, uses the total supply to set the token ID
   * so starts with 0
  */
  function mint(address _to, string _metadata) public onlyOwner() {
    _mint(_to, super.totalSupply());
    _setTokenURI(super.totalSupply()-1, _metadata);
  }

  /**
   * @dev Internal function to mint a new token. Delegates everything to
   * ERC721Token, and then sets the token edition
   * @dev Reverts if the given token ID already exists
   * @param _to address the beneficiary that will own the minted token
   * @param _tokenId uint256 ID of the token to be minted by the msg.sender
   */
  function _mint(address _to, uint256 _tokenId) internal {
    super._mint(_to, _tokenId);

    tokenEditions[_tokenId] = currentEdition_;
  }

}
/**
 * @title Certificates associated with the Machine Learning Engineering Workshop (MLEW)
 * Used to incentivize students and to reward contributors (e.g., peer reviews
 * of the workshop content).
 *
 * Built on OpenZeppelin ERC721 implementation, specifically openzeppelin-solidity v1.12.0
 *
 * This contract has a non-standard functionality: it keeps track of what edition of the
 * workshop a given token was minted for. That information is also surfaced with the metadata.
 * @author Gabriel Parent
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
function incrementEdition() public onlyOwner() {
  currentEdition_ = currentEdition_ + 1;
}

/**
 * @dev Increments the edition, onlyOwner
 */