# Path: partify/priv.py
# def priv_in_english(priv):
#     """Translates a privilege integer into its string representation.
# 
#     :param priv: The privilege to look up
#     :type priv: integer
#     :returns: The string representation of the privilege
#     :rtype: string
#     """
#     return privs_in_english[priv]


from wtforms import BooleanField
from wtforms import Form 
from wtforms import HiddenField
from wtforms import IntegerField
from wtforms import SelectField
from wtforms import TextField
from wtforms import validators
from partify.priv import priv_in_english
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Partify.  If not, see <http://www.gnu.org/licenses/>.

"""Contains forms used for gathering input for administrative features."""



class ConfigurationForm(Form):
    """A WTForm for configuration information.

    Each of the fields should be the loweredcased name of the corresponding configuration field.
    """
    
    selection_scheme = SelectField("Track Selection", [validators.Required()], choices=[('ROUND_ROBIN', 'Round Robin'), ('FCFS_VOTE', 'First-Come, First-Served with Voting'), ('FCFS', 'First-Come, First-Served')])
    mpd_server_hostname = TextField("MPD Server Hostname", [validators.Required()])
    mpd_server_port = IntegerField("MPD Server Port", [validators.Required(), validators.NumberRange(min=0, max=65535)])
    server_host = TextField("Hostname to listen on", [validators.Required()])
    server_port = IntegerField("Port to listen on", [validators.Required(), validators.NumberRange(min=0, max=65535)])
    server = SelectField("Underlying Server Software", [validators.Required()], choices=[('tornado', 'Tornado'), ('builtin', 'Builtin Debugging Server')])
    lastfm_api_key = TextField("Last.fm API Key", [validators.Optional()])
    lastfm_api_secret = TextField("Last.fm API Secret", [validators.Optional()])

def create_single_user_admin_admin_form(user_id):
    """Creates a SingleUserAdminAdminForm that can be used in concert with other SingleUserAdminAdminForms."""

    class SingleUserAdminAdminForm(Form):
        pass
    

# Path: partify/priv.py
# def priv_in_english(priv):
#     """Translates a privilege integer into its string representation.
# 
#     :param priv: The privilege to look up
#     :type priv: integer
#     :returns: The string representation of the privilege
#     :rtype: string
#     """
#     return privs_in_english[priv]


# Path: partify/forms/admin_forms.py
from wtforms import BooleanField
from wtforms import Form 
from wtforms import HiddenField
from wtforms import IntegerField
from wtforms import SelectField
from wtforms import TextField
from wtforms import validators
from partify.priv import priv_in_english

# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Partify.  If not, see <http://www.gnu.org/licenses/>.

"""Contains forms used for gathering input for administrative features."""



class ConfigurationForm(Form):
    """A WTForm for configuration information.

    Each of the fields should be the loweredcased name of the corresponding configuration field.
    """
    
    selection_scheme = SelectField("Track Selection", [validators.Required()], choices=[('ROUND_ROBIN', 'Round Robin'), ('FCFS_VOTE', 'First-Come, First-Served with Voting'), ('FCFS', 'First-Come, First-Served')])
    mpd_server_hostname = TextField("MPD Server Hostname", [validators.Required()])
    mpd_server_port = IntegerField("MPD Server Port", [validators.Required(), validators.NumberRange(min=0, max=65535)])
    server_host = TextField("Hostname to listen on", [validators.Required()])
    server_port = IntegerField("Port to listen on", [validators.Required(), validators.NumberRange(min=0, max=65535)])
    server = SelectField("Underlying Server Software", [validators.Required()], choices=[('tornado', 'Tornado'), ('builtin', 'Builtin Debugging Server')])
    lastfm_api_key = TextField("Last.fm API Key", [validators.Optional()])
    lastfm_api_secret = TextField("Last.fm API Secret", [validators.Optional()])

def create_single_user_admin_admin_form(user_id):
    """Creates a SingleUserAdminAdminForm that can be used in concert with other SingleUserAdminAdminForms."""

    class SingleUserAdminAdminForm(Form):
        pass
    

    setattr(SingleUserAdminAdminForm, "%d_admin_config" % user_id, BooleanField(priv_in_english("ADMIN_CONFIG"), [validators.Required()]))