Esempio n. 1
0
class ArticleRevision(db.Model):
    previous = db.SelfReferenceProperty(indexed=False, collection_name='_1')
    next = db.SelfReferenceProperty(indexed=False, collection_name='_2')
    user = db.ReferenceProperty(User, collection_name='revisions',
                                required=True)
    user_name = db.StringProperty(required=True, indexed=False)
    icon = db.ReferenceProperty(Blob)
    created = db.DateTimeProperty(auto_now_add=True)
    title = db.StringProperty(required=True, indexed=False)
    description = db.StringProperty(required=True, multiline=True,
                                    indexed=False)
    content = db.TextProperty(required=True)
    html = db.TextProperty(required=True)
    message = db.StringProperty(indexed=False)

    @classmethod
    def all_for_article(cls, article):
        """Returns a Query instance that will only return revision instances
        that are bound to the specificed article id/key/instance.

        """
        article = get_key(article, Article)
        return cls.all().ancestor(article)

    @classmethod
    def build_key(cls, article, revision):
        """Returns a key referencing a specific revision instance given an
        article id/key/instance and a revision number.

        """
        article = get_key(article, Article)
        # Build a key that references the requested revision for the specified
        # article.
        return db.Key.from_path(cls.kind(), str(revision), parent=article)
Esempio n. 2
0
class Book(db.Model):
    
    name = db.StringProperty()
    parent_book = db.SelfReferenceProperty(collection_name='child_books')
    child_book = db.SelfReferenceProperty(collection_name='parent_books')
    
    def reference(self):
        return 'trade'
Esempio n. 3
0
class Message(db.Model):
  """A copy of a message sent out in email.

  This is a descendant of an Issue.
  """

  issue = db.ReferenceProperty(Issue)  # == parent
  subject = db.StringProperty()
  sender = db.EmailProperty()
  recipients = db.ListProperty(db.Email)
  date = db.DateTimeProperty(auto_now_add=True)
  text = db.TextProperty()
  draft = db.BooleanProperty(default=False)
  in_reply_to = db.SelfReferenceProperty()

  _approval = None

  @property
  def approval(self):
    """Is True when the message represents an approval of the review."""
    if self._approval is None:
      # Must contain 'lgtm' in a line that doesn't start with '>'.
      self._approval = any(
            True for line in self.text.lower().splitlines()
            if not line.strip().startswith('>') and 'lgtm' in line)
      # Must not be issue owner.
      self._approval &= self.issue.owner.email() != self.sender
    return self._approval
Esempio n. 4
0
class Task(db.Model):
    proposer = db.UserProperty()
    proposed = db.DateTimeProperty()
    uuid = db.StringProperty()
    title = db.StringProperty()
    blocks = db.SelfReferenceProperty()
    status = db.CategoryProperty()
Esempio n. 5
0
class Comment(db.Model):
    """
    COMMENT GoogleAppEngine (Model) for persistance
    """
    post = db.ReferenceProperty(Post,
                                collection_name='post_comments')

    user = db.ReferenceProperty(User,
                                collection_name='user_comments')

    comment_parent = db.SelfReferenceProperty(required=False, default=None,
                                              collection_name='replies')

    comment = db.TextProperty(required=True)
    created_by = db.StringProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)
    last_modified = db.DateTimeProperty(auto_now=True)

    def render(self, post):
        self._render_content = self.comment.replace('\n', '<br />')
        return Handler().render_str("comment.html", comment=self, post=post)

    def render_single(self):
        single_content = self.comment.replace('\n', '<br />')
        self._render_single = single_content
        return Handler().render_str("comment-single-reply.html", comment=self)
Esempio n. 6
0
class AllPropertiesModel(db.Model):
    """Property names are ugly, yes."""
    prop_string = db.StringProperty()
    prop_byte_string = db.ByteStringProperty()
    prop_boolean = db.BooleanProperty()
    prop_integer = db.IntegerProperty()
    prop_float = db.FloatProperty()
    prop_date_time = db.DateTimeProperty()
    prop_date = db.DateProperty()
    prop_time = db.TimeProperty()
    prop_list = db.ListProperty(int)
    prop_string_list = db.StringListProperty()
    prop_reference = db.ReferenceProperty()
    prop_self_refeference = db.SelfReferenceProperty()
    prop_user = db.UserProperty()
    prop_blob = db.BlobProperty()
    prop_text = db.TextProperty()
    prop_category = db.CategoryProperty()
    prop_link = db.LinkProperty()
    prop_email = db.EmailProperty()
    prop_geo_pt = db.GeoPtProperty()
    prop_im = db.IMProperty()
    prop_phone_number = db.PhoneNumberProperty()
    prop_postal_address = db.PostalAddressProperty()
    prop_rating = db.RatingProperty()
Esempio n. 7
0
class RecordVersion(db.Model):
	record				= db.ReferenceProperty(Record)
	reference			= db.StringProperty()
	header				= db.TextProperty()
	data				= db.TextProperty()
	version				= db.StringProperty()
	previousVersionKey	= db.StringProperty()
	previousVersion		= db.SelfReferenceProperty()
	creation_date		= db.DateTimeProperty(auto_now_add=True)
	update_date			= db.DateTimeProperty(auto_now_add=True)
	access_date			= db.DateTimeProperty(auto_now_add=True)

	def update(self, someData):
		recordData = someData['record'];
		self.parent().reference =	recordData['reference']
		self.parent().data =		recordData['data']
		self.parent().version =		recordData['version']
		self.parent().update_date =	datetime.datetime.now()

		recordVersionData = someData['currentRecordVersion'];
		self.reference =			recordVersionData ['reference']
		self.data =					recordVersionData ['data']
		self.version =				recordVersionData ['version']
		#self.previous_version	=	#recordVersionData ['previousVersion']
		self.previous_version_key =	recordVersionData ['previousVersionKey']
		self.update_date =			datetime.datetime.now()
Esempio n. 8
0
class Chat(db.Model):
  author = db.UserProperty(required=True)
  author_ip = db.StringProperty(required=True)
  art = db.ReferenceProperty(Article)
  postdate = db.DateTimeProperty(auto_now_add=True)
  text = db.StringProperty(required=True,multiline=True)
  parent_chat = db.SelfReferenceProperty()
Esempio n. 9
0
class UserChat(db.Model):
    # parent: User
    # id or key_name: Chat id or key_name
    name = db.StringProperty(required=True)
    peer_userchat = db.SelfReferenceProperty()
    title = db.StringProperty(required=True, indexed=False)
    last_updated = db.DateTimeProperty()
Esempio n. 10
0
class Tweet(db.Model):
    author = db.ReferenceProperty(TwitterAccount, collection_name='tweets')
    text = db.StringProperty(required=True)
    in_reply_to = db.SelfReferenceProperty(collection_name='replies')
    mentions = db.ListProperty(db.Key)
    created_at = db.DateProperty()
    geo = db.GeoPtProperty()
Esempio n. 11
0
class Thread(search.SearchableModel):
	community = db.ReferenceProperty(Community,required=True)
	community_title = db.StringProperty()
	community_url_path = db.StringProperty()
	author = db.ReferenceProperty(UserData,required=True)
	author_nickname = db.StringProperty()
	title = db.StringProperty(required=True)
	url_path = db.StringProperty()
	content = db.TextProperty(required=True)
	subscribers = db.StringListProperty()
	
	last_response_date = db.DateTimeProperty()
	response_number = db.IntegerProperty()
	
	editions = db.IntegerProperty()
	last_edition = db.DateTimeProperty()
	
	# responses
	parent_thread = db.SelfReferenceProperty()
	
	responses = db.IntegerProperty(required=True)
	latest_response = db.DateTimeProperty()

	last_update = db.DateTimeProperty(auto_now=True)
	creation_date = db.DateTimeProperty(auto_now_add=True)
	deletion_date = db.DateTimeProperty()
	
	deletion_message = db.StringProperty()
	views = db.IntegerProperty()
Esempio n. 12
0
class Pantalla(db.Model):
    nombre = db.StringProperty()
    titulo = db.StringProperty()
    url = db.StringProperty()
    orden = db.IntegerProperty()
    padre = db.SelfReferenceProperty()
    visible = db.BooleanProperty()
    admin = db.BooleanProperty()
Esempio n. 13
0
class Revision(db.Model):
    author = db.UserProperty()
    date = db.DateTimeProperty(auto_now_add=True)
    content = db.TextProperty()
    #    diff = db.TextProperty()
    #    file = db.ReferenceProperty(File)
    file = db.ReferenceProperty(collection_name='file')
    prev = db.SelfReferenceProperty()
Esempio n. 14
0
class Comment(db.Model):
    """文章的评论"""
    name = db.StringProperty(verbose_name='称呼', default='')
    email = db.EmailProperty(verbose_name='E-mail', default='')
    content = db.StringProperty(verbose_name='内容',default='')
    father = db.SelfReferenceProperty()
    post_id = db.IntegerProperty(default=0)
    post = db.ReferenceProperty(Post)
Esempio n. 15
0
class ViewMap(BaseModel):
    is_root = db.BooleanProperty()
    title = db.StringProperty(required=False)
    url = db.StringProperty(required=False)
    org = db.StringProperty(required=False)
    view_definition = db.ReferenceProperty(ViewDefinition, required=False)
    metadata = db.ReferenceProperty(Metadata, required=False)
    parent_viewmap = db.SelfReferenceProperty(required=False)
Esempio n. 16
0
class DBComments(db.Model):
    obj = db.ReferenceProperty(collection_name="objects")
    content = db.TextProperty()
    date = db.DateTimeProperty(auto_now_add=True)
    user = db.ReferenceProperty(DBUser, collection_name="users")
    parent_comment = db.SelfReferenceProperty(
        collection_name="parent_comments")
    rating = db.IntegerProperty()
Esempio n. 17
0
class Issue(db.Model):
    summary = db.StringProperty()
    description = db.TextProperty()
    creator_user = db.UserProperty()
    state = db.StringProperty()
    resolution = db.StringProperty()
    priority = db.IntegerProperty()
    type = db.StringProperty()
    duplicate_of = db.SelfReferenceProperty()
Esempio n. 18
0
class Category(db.Model):
	parent_category = db.SelfReferenceProperty()
	title = db.StringProperty(required=True)
	url_path = db.StringProperty()
	description = db.StringProperty(required=True)
	communities = db.IntegerProperty(required=True)
	articles = db.IntegerProperty(required=True)
	
	subcategories = None
Esempio n. 19
0
class Area(DerefModel):
    name = db.StringProperty(required=True)
    zone = db.ReferenceProperty(Zone, required=True)
    district = db.SelfReferenceProperty(collection_name='district_area_set')
    ward = db.ReferenceProperty(Ward, indexed=False)
    reports_with = db.SelfReferenceProperty()
    does_not_report = db.BooleanProperty()
    phone = db.StringProperty()

    # auto update
    is_open = db.BooleanProperty()
    zone_name = db.StringProperty()

    def __unicode__(self):
        return self.zone_name + ' - ' + self.name

    def __str__(self):
        return self.__unicode__()
Esempio n. 20
0
class PlaceMessage(db.Model):
    num = db.IntegerProperty(indexed=True)
    place = db.ReferenceProperty(Place)
    place_num = db.IntegerProperty(indexed=True)
    member = db.ReferenceProperty(Member)
    content = db.TextProperty(required=False)
    in_reply_to = db.SelfReferenceProperty()
    source = db.StringProperty(required=False, indexed=True)
    created = db.DateTimeProperty(auto_now_add=True)
Esempio n. 21
0
class Reason(db.Model):
    created = db.DateTimeProperty(auto_now_add=True)
    text = db.StringProperty(required=True)
    is_citation = db.BooleanProperty(required=True)
    reason_for = db.ReferenceProperty(collection_name='reasons_for_set')
    reason_against = db.ReferenceProperty(
        collection_name='reasons_against_set')
    citation_for = db.SelfReferenceProperty(collection_name="citation_set")
    reasoned = db.ReferenceProperty(collection_name="reasoned_set")
Esempio n. 22
0
class _PipelineRecord(db.Model):
  """Represents a Pipeline.

  Properties:
    class_path: Path of the Python class to use for this pipeline.
    root_pipeline: The root of the whole workflow; set to itself this pipeline
      is its own root.
    fanned_out: List of child _PipelineRecords that were started when this
      generator pipeline moved from WAITING to RUN.
    start_time: For pipelines with no start _BarrierRecord, when this pipeline
      was enqueued to run immediately.
    finalized_time: When this pipeline moved from WAITING or RUN to DONE.
    params: Serialized parameter dictionary.
    status: The current status of the pipeline.
    current_attempt: The current attempt (starting at 0) to run.
    max_attempts: Maximum number of attempts (starting at 0) to run.
    next_retry_time: ETA of the next retry attempt.
    retry_message: Why the last attempt failed; None or empty if no message.

  Root pipeline properties:
    is_root_pipeline: This is a root pipeline.
    abort_message: Why the whole pipeline was aborted; only saved on
      root pipelines.
    abort_requested: If an abort signal has been requested for this root
      pipeline; only saved on root pipelines
  """

  WAITING = 'waiting'
  RUN = 'run'
  DONE = 'done'
  ABORTED = 'aborted'

  class_path = db.StringProperty()
  root_pipeline = db.SelfReferenceProperty(
                      collection_name='child_pipelines_set')
  fanned_out = db.ListProperty(db.Key, indexed=False)
  start_time = db.DateTimeProperty(indexed=False)
  finalized_time = db.DateTimeProperty(indexed=False)
  params = ParamsProperty()
  status = db.StringProperty(choices=(WAITING, RUN, DONE, ABORTED),
                             default=WAITING)

  # Retry behavior
  current_attempt = db.IntegerProperty(default=0, indexed=False)
  max_attempts = db.IntegerProperty(default=1, indexed=False)
  next_retry_time = db.DateTimeProperty(indexed=False)
  retry_message = db.TextProperty()

  # Root pipeline properties
  is_root_pipeline = db.BooleanProperty()
  abort_message = db.TextProperty()
  abort_requested = db.BooleanProperty(indexed=False)

  @classmethod
  def kind(cls):
    return '_AE_Pipeline_Record'
Esempio n. 23
0
class Task(db.Model):
    """ Defines a database model for storing Tasks """
    owner = db.UserProperty()
    name = db.StringProperty(multiline=False)
    task_list = db.ReferenceProperty(TaskList)  #reference to a TaskList
    due_date = db.DateTimeProperty()
    start_date = db.DateTimeProperty()
    percent_complete = db.IntegerProperty()
    assigned_members = db.ListProperty(users.User)  #list of Users
    notes = db.TextProperty()
    parent_task = db.SelfReferenceProperty(collection_name='parent_set')
Esempio n. 24
0
class Recipe(db.Model):
    name = db.StringProperty()
    recipe = db.SelfReferenceProperty()
    created_on = db.DateTimeProperty(auto_now_add=1)
    created_by = db.UserProperty()

    def __str__(self):
        return '%s' % self.name

    def get_absolute_url(self):
        return '/recipe/%s/' % self.key()
Esempio n. 25
0
class Comment(db.Model):
    message = db.TextProperty()
    user = db.ReferenceProperty(User, collection_name='comments')
    post = db.ReferenceProperty(Post, collection_name='comments')
    father = db.SelfReferenceProperty(collection_name='childs')
    created = db.DateTimeProperty(auto_now_add=True)
    karma = db.FloatProperty()

    def sum_votes(self):
        val = memcache.get("c_" + str(self.key()))
        if val is not None:
            return val
        else:
            val = self.votes.count()
            memcache.add("c_" + str(self.key()), val, 3600)
            return val

    def already_voted(self):
        session = get_current_session()
        if session.has_key('user'):
            user = session['user']
            # hit memcache for this
            memValue = data = memcache.get("cp_" + str(self.key()) + "_" +
                                           str(user.key()))
            if memValue is not None:
                return True
            else:
                vote = [v for v in self.votes if v.user.key() == user.key()]
                if len(vote) == 0:
                    return False
                else:
                    memcache.add(
                        "cp_" + str(self.key()) + "_" + str(user.key()), 1,
                        3600)
                    return True
        else:
            return False

    def remove_from_memcache(self):
        memcache.delete("c_" + str(self.key()))
        session = get_current_session()
        if session.has_key('user'):
            user = session['user']
            user.remove_from_memcache()
            memcache.delete("cp_" + str(self.key()) + "_" + str(user.key()))
        self.calculate_karma()

    def calculate_karma(self):
        delta = (datetime.now() - self.created)
        seconds = delta.seconds + delta.days * 86400
        hours = seconds / 3600 + 1
        self.karma = float(self.sum_votes() / hours)
        self.karma = self.karma * self.karma
        self.put()
Esempio n. 26
0
class UserModel(db.Model): # pylint: disable=R0904
    """
    Stores user information. Also provides the methods needed to Flask-Login.
    
    .. method:: User(firstName, lastName, cwruID, salt, hash[, middleName, contractType, family, big, avatar])

       Creates a new User entity

       :param firstName: User's first name
       :type firstName: unicode

       :param lastName: User's last name
       :type lastName: unicode

       :param cwruID: User's Case network ID.
       :type cwruID: unicode

       :param salt: A unique string (per user) used in password hashing
       :type salt: unicode

       :param hash: A hash of the user's password with the user's salt
       :type hash: unicode

       :param middleName: User's middle name
       :type middleName: unicode

       :param contractType: User's Contract type
       :type contractType: application.models.Contract

       :param family: User's family
       :type family: application.models.Family

       :param big: User's big
       :type big: application.models.User

       :param avatar: User's gravatar user name
       :type avatar: unicode
    """
    # Required attributes
    fname = db.StringProperty(required=True)
    lname = db.StringProperty(required=True)
    cwruid = db.StringProperty(required=True)
    salt = db.StringProperty(required=True)
    hash = db.StringProperty(required=True)

    # Optional attributes
    mname = db.StringProperty(default=None)
    # might want to enforce reference type on contractType and family
    contract_type = db.ReferenceProperty(default=None,
                                        collection_name='contract')
    family = db.ReferenceProperty(default=None,
                                  collection_name='family')
    big = db.SelfReferenceProperty(default=None, collection_name='littles')
    avatar = db.StringProperty(default=None)
Esempio n. 27
0
class TestEntity(entities.BaseEntity):
    prop_int = db.IntegerProperty()
    prop_float = db.FloatProperty(required=True)
    prop_bool = db.BooleanProperty()
    prop_string = db.StringProperty()
    prop_text = db.TextProperty()
    prop_date = db.DateProperty()
    prop_datetime = db.DateTimeProperty()
    prop_intlist = db.ListProperty(int)
    prop_stringlist = db.StringListProperty()
    prop_ref = db.SelfReferenceProperty()
Esempio n. 28
0
class Account(db.Model):
    user = db.UserProperty()

    invited_by = db.SelfReferenceProperty()

    created_at = db.DateTimeProperty(auto_now_add=True)
    updated_at = db.DateTimeProperty(auto_now=True)

    profile_created = db.BooleanProperty(required=True, default=False)
    newsletter = db.BooleanProperty(default=True)
    full_name = db.StringProperty()
Esempio n. 29
0
class DefaultConstructableEntity(entities.BaseEntity):
    prop_int = db.IntegerProperty()
    prop_float = db.FloatProperty()
    prop_bool = db.BooleanProperty()
    prop_string = db.StringProperty()
    prop_text = db.TextProperty()
    prop_date = db.DateProperty()
    prop_datetime = db.DateTimeProperty()
    prop_intlist = db.ListProperty(int)
    prop_stringlist = db.StringListProperty()
    prop_ref = db.SelfReferenceProperty()
Esempio n. 30
0
class Worker(datastore.Model):
    created = datastore.DateTimeProperty(auto_now_add=True)
    id = datastore.StringProperty()
    assignment_id = datastore.StringProperty()
    experiment = datastore.ReferenceProperty(Experiment)
    peer_worker = datastore.SelfReferenceProperty()
    cohort_index = datastore.IntegerProperty()
    nonce = datastore.StringProperty()

    def has_labeled_an_image(self):
        return self.labelings.count() > 0