def _make_comment_options(self, username, moderator): """Helper method to create the parts of the COMMENT_OPTIONS javascript that are unique to each request. :param username: The username of the user making the request. :param moderator: Whether the user making the request is a moderator. """ rv = self.base_comment_opts.copy() if username: rv.update({ 'voting': True, 'username': username, 'moderator': moderator, }) return '''\ <script type="text/javascript"> var COMMENT_OPTIONS = %s; </script> ''' % dump_json(rv)
def _make_metadata(self, data): return '''\ <script type="text/javascript"> var COMMENT_METADATA = %s; </script> ''' % dump_json(data)