# Path: app/accounts/models.py
# class Project(db.Model, models.BaseModelMixin, models.CreateAndModifyMixin):
#     __tablename__ = 'projects'
# 
#     title = db.Column(db.Unicode(255), nullable=False)
# 
#     intercom_app_id = db.Column(db.Unicode(255), nullable=False, unique=True)
#     intercom_api_key = db.Column(db.Unicode(255), nullable=False)
#     intercom_webhooks_internal_secret = db.Column(db.Unicode(255))
#     intercom_subscription_id = db.Column(db.Unicode(255))
# 
#     aws_access_id = db.Column(db.Unicode(255), nullable=False)
#     aws_secret_access_key = db.Column(db.Unicode(255), nullable=False)
# 
#     user_id = db.Column(db.Integer(), db.ForeignKey('users.id'),
#                         nullable=False)
#     user = db.relationship('User', back_populates='projects')
# 
#     intercom_users = db.relationship('IntercomUser',
#                                      back_populates='project')
# 
#     def __unicode__(self):
#         return self.title
# 
#     @classmethod
#     def get_for_current_user_or_404(cls, pk):
#         return cls.get_or_404(cls.user_id == current_user.id, cls.id == pk)
# 
#     def get_intercom_client(project):
#         from app.intercom.service import IntercomClient
#         return IntercomClient(project.intercom_app_id,
#                               project.intercom_api_key)
# 
#     def start_awis_session(project):
#         """ Initiate contextmanager for working with AWIS.
#         """
#         return AWISContextManager(project.aws_access_id,
#                                   project.aws_secret_access_key)
# 
#     def delete(self):
#         client = self.get_intercom_client()
#         client.unsubscribe(self.intercom_subscription_id)
#         return super(Project, self).delete()
# 
# class FreeEmailProvider(db.Model, models.BaseModelMixin):
#     __tablename__ = 'free_email_providers'
# 
#     domain = db.Column(db.Unicode(255), nullable=False, index=True)
# 
#     def __unicode__(self):
#         return self.domain
# 
#     @classmethod
#     def exists(cls, domain):
#         return bool(cls.query.filter(cls.domain == domain).first())
# 
# Path: common/forms.py
# class BaseForm(Form):
#     """ Our base class for forms.
#     """
#     def __init__(self, *args, **kwargs):
#         super(BaseForm, self).__init__(*args, **kwargs)
#         self.obj = kwargs.get('obj')
# 
# class TrackChangesStringField(TrackChangesMixin, StringField):
#     pass


import uuid
from flask import url_for
from flask.ext.login import current_user
from wtforms import SubmitField
from wtforms.validators import DataRequired, ValidationError
from app.accounts.models import Project, FreeEmailProvider
from common.forms import BaseForm, TrackChangesStringField




def default_string_field(label, **extra):
    validators = extra.pop('validators', [])
    validators.append(DataRequired())

# Path: app/accounts/models.py
# class Project(db.Model, models.BaseModelMixin, models.CreateAndModifyMixin):
#     __tablename__ = 'projects'
# 
#     title = db.Column(db.Unicode(255), nullable=False)
# 
#     intercom_app_id = db.Column(db.Unicode(255), nullable=False, unique=True)
#     intercom_api_key = db.Column(db.Unicode(255), nullable=False)
#     intercom_webhooks_internal_secret = db.Column(db.Unicode(255))
#     intercom_subscription_id = db.Column(db.Unicode(255))
# 
#     aws_access_id = db.Column(db.Unicode(255), nullable=False)
#     aws_secret_access_key = db.Column(db.Unicode(255), nullable=False)
# 
#     user_id = db.Column(db.Integer(), db.ForeignKey('users.id'),
#                         nullable=False)
#     user = db.relationship('User', back_populates='projects')
# 
#     intercom_users = db.relationship('IntercomUser',
#                                      back_populates='project')
# 
#     def __unicode__(self):
#         return self.title
# 
#     @classmethod
#     def get_for_current_user_or_404(cls, pk):
#         return cls.get_or_404(cls.user_id == current_user.id, cls.id == pk)
# 
#     def get_intercom_client(project):
#         from app.intercom.service import IntercomClient
#         return IntercomClient(project.intercom_app_id,
#                               project.intercom_api_key)
# 
#     def start_awis_session(project):
#         """ Initiate contextmanager for working with AWIS.
#         """
#         return AWISContextManager(project.aws_access_id,
#                                   project.aws_secret_access_key)
# 
#     def delete(self):
#         client = self.get_intercom_client()
#         client.unsubscribe(self.intercom_subscription_id)
#         return super(Project, self).delete()
# 
# class FreeEmailProvider(db.Model, models.BaseModelMixin):
#     __tablename__ = 'free_email_providers'
# 
#     domain = db.Column(db.Unicode(255), nullable=False, index=True)
# 
#     def __unicode__(self):
#         return self.domain
# 
#     @classmethod
#     def exists(cls, domain):
#         return bool(cls.query.filter(cls.domain == domain).first())
# 
# Path: common/forms.py
# class BaseForm(Form):
#     """ Our base class for forms.
#     """
#     def __init__(self, *args, **kwargs):
#         super(BaseForm, self).__init__(*args, **kwargs)
#         self.obj = kwargs.get('obj')
# 
# class TrackChangesStringField(TrackChangesMixin, StringField):
#     pass


# Path: app/accounts/forms.py
import uuid
from flask import url_for
from flask.ext.login import current_user
from wtforms import SubmitField
from wtforms.validators import DataRequired, ValidationError
from app.accounts.models import Project, FreeEmailProvider
from common.forms import BaseForm, TrackChangesStringField





def default_string_field(label, **extra):
    validators = extra.pop('validators', [])
    validators.append(DataRequired())

    return TrackChangesStringField(label, validators=validators, **extra)