# Path: codebox/apps/snippets/models.py
# class Snippet(Model):
#     org = String()
#     user = String()
#     text = String()
#     keywords = String(required=False)
#     lang = String()
#     created_at = Float(default=time.time)
# 
#     languages = [
#         ('text', 'Plaintext'),
#         ('diff', 'Diff'),
#         ('javascript', 'JavaScript'),
#         ('html', 'HTML'),
#         ('php', 'PHP'),
#         ('python', 'Python'),
#         ('ruby', 'Ruby'),
#         ('applescript', 'AppleScript'),
#         ('bash', 'Bash'),
#         ('c', 'C'),
#         ('c++', 'C++'),
#         ('css', 'CSS'),
#         ('erlang', 'Erlang'),
#         ('java', 'Java'),
#         ('scala', 'Scala'),
#         ('sql', 'SQL'),
#         ('xml', 'XML'),
#     ]
# 
#     class Meta:
#         index = (('org',), ('user',))
# 
#     def post_create(self):
#         from codebox.apps.organizations.models import Organization
#         # Fill our dashboard index
#         for user in Organization.objects.get(self.org).get_all_members():
#             Snippet.objects.add_to_index(self.pk, dashboard=user.pk)
#     
#     def get_user(self):
#         return User.objects.get(self.user)


from flaskext.wtf import Form, TextField, TextAreaField, Required, SelectField
from codebox.apps.snippets.models import Snippet

class NewSnippetForm(Form):
    lang = SelectField('Language', choices=Snippet.languages, validators=[Required()])
    text = TextAreaField('Snippet', validators=[Required()])
    keywords = TextField('Keywords')

class EditSnippetForm(Form):

# Path: codebox/apps/snippets/models.py
# class Snippet(Model):
#     org = String()
#     user = String()
#     text = String()
#     keywords = String(required=False)
#     lang = String()
#     created_at = Float(default=time.time)
# 
#     languages = [
#         ('text', 'Plaintext'),
#         ('diff', 'Diff'),
#         ('javascript', 'JavaScript'),
#         ('html', 'HTML'),
#         ('php', 'PHP'),
#         ('python', 'Python'),
#         ('ruby', 'Ruby'),
#         ('applescript', 'AppleScript'),
#         ('bash', 'Bash'),
#         ('c', 'C'),
#         ('c++', 'C++'),
#         ('css', 'CSS'),
#         ('erlang', 'Erlang'),
#         ('java', 'Java'),
#         ('scala', 'Scala'),
#         ('sql', 'SQL'),
#         ('xml', 'XML'),
#     ]
# 
#     class Meta:
#         index = (('org',), ('user',))
# 
#     def post_create(self):
#         from codebox.apps.organizations.models import Organization
#         # Fill our dashboard index
#         for user in Organization.objects.get(self.org).get_all_members():
#             Snippet.objects.add_to_index(self.pk, dashboard=user.pk)
#     
#     def get_user(self):
#         return User.objects.get(self.user)


# Path: codebox/apps/snippets/forms.py
from flaskext.wtf import Form, TextField, TextAreaField, Required, SelectField
from codebox.apps.snippets.models import Snippet


class NewSnippetForm(Form):
    lang = SelectField('Language', choices=Snippet.languages, validators=[Required()])
    text = TextAreaField('Snippet', validators=[Required()])
    keywords = TextField('Keywords')

class EditSnippetForm(Form):

    lang = SelectField('Language', choices=Snippet.languages, validators=[Required()])