class NewStyleIndexesTestModel(models.Model): f1 = models.IntegerField() f2 = models.IntegerField() f3 = models.IntegerField() db_index = models.IntegerField(db_index=True) unique = models.IntegerField(unique=True) custom_column = models.IntegerField(db_column='custom') geo = models.IntegerField() geo_custom_column = models.IntegerField(db_column='geo') dict1 = DictField() dict_custom_column = DictField(db_column='dict_custom') embedded = EmbeddedModelField(CustomColumnEmbeddedModel) embedded_list = ListField(EmbeddedModelField(CustomColumnEmbeddedModel)) class Meta: unique_together = [('f2', 'custom_column'), ('f2', 'f3')] class MongoMeta: indexes = [ [('f1', -1)], {'fields': 'f2', 'sparse': True}, {'fields': [('custom_column', -1), 'f3']}, [('geo', '2d')], {'fields': [('geo_custom_column', '2d'), 'f2'], 'min': 42, 'max': 21}, {'fields': [('dict1.foo', 1)]}, {'fields': [('dict_custom_column.foo', 1)]}, {'fields' :[('embedded.a', 1)]}, {'fields' :[('embedded_list.a', 1)]}, ]
class Answer(models.Model): id = models.AutoField(primary_key=True) author = models.OneToOneField(User) publishedDate = models.CharField(max_length=128) likes = ListField(EmbeddedModelField(User)) answerText = models.TextField() comments = ListField(EmbeddedModelField('Comment')) isAccepted = models.IntegerField()
class Exam(models.Model): name = models.CharField(max_length=50) lessons = ListField(EmbeddedModelField('Lesson')) choices = ListField(EmbeddedModelField('Choicesingle')) readings = ListField(EmbeddedModelField('Reading')) totalpoints = models.IntegerField(blank=True, default=0) withtrans = models.BooleanField(default=True) tag = models.CharField(max_length=50, blank=True, null=True)
class Movie(models.Model): created_on = models.DateTimeField(auto_now_add=True) actors = ListField(EmbeddedModelField('Actor')) director = EmbeddedModelField('Director') tags = ListField(EmbeddedModelField('Tag')) text = models.TextField() title = models.CharField() year = models.CharField()
class DocumentSenat(models.Model): deposition_date = models.CharField(max_length=1337) type = DictField() comments = DictField() ending_date = models.CharField(max_length=1337) author = models.CharField(max_length=1337) pdf = EmbeddedModelField('DocumentSenatPdf') comments = DictField() status = DictField() other_pdfs = ListField(EmbeddedModelField('OtherDocumentSenatPdf'))
class Thread(models.Model): id = models.AutoField(primary_key=True) title = models.CharField(max_length=128) author = models.OneToOneField(User) publishedDate = models.CharField(max_length=128) questionText = models.TextField() answers = ListField(EmbeddedModelField('Answer')) likes = ListField(EmbeddedModelField(User)) tags = ListField(EmbeddedModelField(Skill)) comments = ListField(EmbeddedModelField('Comment'))
class Event(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE) eventName = models.CharField(max_length=50) startdate = models.DateField() enddate = models.DateField() description = models.CharField(max_length=50) organiser = models.CharField(max_length=50) mentorList = ListField(EmbeddedModelField(User)) skillList = ListField(EmbeddedModelField(Skill)) def __str__(self): return self.eventName
class DocumentChambre(models.Model): deposition_date = models.CharField(max_length=1337) type = DictField() taken_in_account_date = models.CharField(max_length=1337) distribution_date = models.CharField(max_length=1337) sending_date = models.CharField(max_length=1337) ending_date = models.CharField(max_length=1337) status = DictField() authors = ListField() comments = DictField() pdf = EmbeddedModelField('DocumentChambrePdf') other_pdfs = ListField(EmbeddedModelField('OtherDocumentChambrePdf')) joint_pdfs = ListField()
class Test(models.Model): creator = EmbeddedModelField('Person', null=True) exectype = models.CharField(max_length=255) fix_versions = ListField(EmbeddedModelField('FixVersion')) funnel = models.TextField() jiraid = models.IntegerField(null=True) issuelinks = ListField(EmbeddedModelField('IssueLink')) issuetype = models.CharField(max_length=255) key = models.CharField(max_length=255, primary_key=True) summary = models.TextField() updated = models.DateTimeField(null=True) target = models.CharField(max_length=255) result = models.CharField(max_length=255)
class Annotation(models.Model): jsonld_context = ListField( models.CharField( max_length = 4096 ) ) # ["http://www.w3.org/ns/anno.jsonld"] # 20160706, [email protected] # Should allow list of which link string would be one item, however needs # to be string when alone. How compatibility of Django data model # declaration with specification can be obtained is unclear at this point. jsonld_id = models.CharField( max_length = 4096 ) type = ListField( models.CharField( max_length = 256 ) ) # (rdf:type) oa:Annotation and others body = ListField( EmbeddedModelField(), null=True ) # CharField( max_length = 4096, null = True ) target = ListField( EmbeddedModelField() ) # models.CharField( max_length = 4096 ) creator = ListField( EmbeddedModelField("Agent"), null=True ) # dcterms:creator created = models.DateTimeField( auto_now_add=True, null=True ) # dcterms:created MUST xsd:dateTime with the UTC timezone expressed as "Z". generator = ListField( EmbeddedModelField("Agent"), null=True ) # prov:wasGeneratedBy generated = models.DateTimeField( auto_now=True, null=True ) # prov:generatedAtTime MUST xsd:dateTime with the UTC timezone expressed as "Z". modified = models.DateTimeField( null=True ) # MUST xsd:dateTime with the UTC timezone expressed as "Z". #modified = models.DateTimeField( auto_now=True, null=True ) # MUST xsd:dateTime with the UTC timezone expressed as "Z". #audience = ListField( EmbeddedModelField("Audience"), null=True ) #rights = ListField( models.CharField( max_length = 4096 ), null=True ) # MAY be then MUST be an IRI #canonical = models.CharField( max_length = 4096, null=True ) # IRI #via = ListField( models.CharField( max_length = 4096, null=True ) ) # IRIs ASSESSING = "assessing" BOOKMARKING = "bookmarking" CLASSIFYING = "classifying" COMMENTING = "commenting" DESCRIBING = "describing" EDITING = "editing" HIGHLIGHTING = "highlighting" IDENTIFYING = "identifying" LINKING = "linking" MODERATING = "moderating" QUESTIONING = "questioning" REPLYING = "replying" TAGGING = "tagging" MOTIVATION_CHOICES = ( (ASSESSING, "assessing"), # oa:assessing (BOOKMARKING, "bookmarking"), # oa:bookmarking (CLASSIFYING, "classifying"), # oa:classifying (COMMENTING, "commenting"), # oa:commenting (DESCRIBING, "describing"), # oa:describing (EDITING, "editing"), # oa:editing (HIGHLIGHTING, "highlighting"), # oa:highlighting (IDENTIFYING, "identifying"), # oa:identifying (LINKING, "linking"), # oa:linking (MODERATING, "moderating"), # oa:moderating (QUESTIONING, "questioning"), # oa:questioning (REPLYING, "replying"), # oa:replying (TAGGING, "tagging"), # oa:tagging ) motivation = ListField( models.CharField( max_length = 256, choices=MOTIVATION_CHOICES ), null=True ) # oa:motivatedBy = [oa:Motivation] #stylesheet = EmbeddedModelField( "CssStyleSheet", null=True ) #oa:styledBy objects = MongoDBManager() # http://stackoverflow.com/questions/23546480/no-raw-query-method-in-my-django-object
class Execution(models.Model): assignee = EmbeddedModelField('Person', null=True) comment = models.TextField() creationDate = models.DateTimeField(null=True) cycleId = models.FloatField(null=True) cycleName = models.CharField(max_length=255) executedBy = EmbeddedModelField('Person', null=True) executedOn = models.DateTimeField(null=True) executionDefects = ListField() execId = models.FloatField(primary_key=True) testcase = EmbeddedModelField('Test', null=True) tckey = models.CharField(max_length=255) status = models.CharField(max_length=255) versionName = models.CharField(max_length=255)
class TestOldEmbeddedArticle(models.Model): class Meta: # Used for testing migrations using same MongoDB collection db_table = 'mongom2m_testapp_testarticle' objects = MongoDBManager() main_category = models.ForeignKey( TestCategory, related_name='main_oldembeddedarticles') categories = ListField(EmbeddedModelField(TestCategory)) tags = ListField(EmbeddedModelField(TestTag)) title = models.CharField(max_length=254) text = models.TextField() def __unicode__(self): return self.title
class PE(models.Model): name = models.TextField() compile_time = models.DateField() imphash = models.TextField() imports = ListField(EmbeddedModelField('PE_Ports')) exports = ListField(EmbeddedModelField('PE_Ports')) sections = ListField() machine = models.TextField() entrypoint = models.TextField() is_dll = models.BooleanField(default=False) subsystem = models.TextField() sub = ListField(EmbeddedModelField('PE_Sub')) version_info = DictField() signature = DictField() packer = ListField()
class HealthCondition(models.Model): name = models.CharField(null=False, max_length=50) description = models.TextField(max_length=255) intro_question = ListField(EmbeddedModelField('IntroQuestion')) #(How is your "skin/condition" today?) hunch = ListField(EmbeddedModelField('Hunch')) status = models.CharField(choices=STATUS_CHOICES, default='A', max_length=1) created_by = models.ForeignKey('auth.User', related_name='condition') created_ts = models.DateTimeField(auto_now_add=True) class MongoMeta: indexes = [ [('name', 1)], [('status', 1)], [('created_by', -1)], [('created_ts', -1)], ]
class Person(models.Model): objects = MongoDBManager() name = models.CharField(max_length=255) texts = ListField(EmbeddedModelField('TextSet')) ids = ListField(EmbeddedModelField('Id')) nameVariants = ListField() deepestPaths = ListField(EmbeddedModelField('Path')) # deepestPaths = ListField(DictField()) class MongoMeta: indexes = [[('name', 1)]]
class Ticket(Model): member = models.ForeignKey(Member) bet_list = ListField(EmbeddedModelField('Bet')) cost = models.IntegerField() def get_obj_details(self): return "%d comb. %s F" % (len(self.bet_list), intcomma(self.cost))
class UserProfile(models.Model): balance = models.IntegerField() user = models.ForeignKey(User, unique=True) riding = EmbeddedModelField(Riding, null=True) def check_in(self, car, stop): self.riding = Riding(car=car, boarded=stop) self.save() def check_out(self, stop): if self.riding == None: raise self.NotCheckedInException fare = self.riding.car.ride(self.user, self.riding.boarded, stop) self.riding = None self.save() return fare #Thrown when you try to check out and not checked in class NotCheckedInException(Exception): pass #Thrown when you can't afford something class InsufficientFundsException(Exception): pass class Meta: app_label = "game"
class Level(Model, ResultsTracker): """ A school level """ name = models.CharField( _("Name"), max_length=30, help_text=_("<strong>Eg:</strong> Form1, Form2, ...")) slug = models.SlugField() registration_fees = models.IntegerField(_("Registration fees"), default=0) first_instalment = models.IntegerField(_("First instalment"), default=0) second_instalment = models.IntegerField(_("Second instalment"), default=0) third_instalment = models.IntegerField(_("Third instalment"), default=0) order_of_appearance = models.IntegerField(default=0) subject_coefficient_list = ListField( EmbeddedModelField('SubjectCoefficient')) class Meta: unique_together = ( ('name', 'school_year'), ('slug', 'school_year'), ) ordering = ('order_of_appearance', 'name') def __unicode__(self): return self.name
class Book(models.Model): name = models.CharField(max_length=50) lessons = ListField(EmbeddedModelField('Lesson')) is_public = models.BooleanField(default=True) def __unicode__(self): return self.name
class Reading(models.Model): name = models.CharField(max_length=100) article = models.TextField() questions = ListField(EmbeddedModelField('Choicesingle')) def __unicode__(self): return self.name
class Post(models.Model): created_at = models.DateTimeField(auto_now_add=True) title = models.CharField(max_length=255) slug = models.SlugField() comments = ListField(EmbeddedModelField('Comment'), editable=False) post_type = models.CharField(max_length=1, choices=POST_CHOICES, default='p') body = models.TextField(blank=True, help_text="The body of the Post / Quote") embed_code = models.TextField(blank=True, help_text="The embed code for video") image_url = models.URLField(blank=True, help_text="Image src") author = models.CharField(blank=True, max_length=255, help_text="Author name") def get_absolute_url(self): return reverse('post', kwargs={"slug": self.slug}) def __unicode__(self): return self.title class Meta: ordering = ["-created_at"]
class Classroom(Model, ResultsTracker): STUDENT_THRESHOLD = 3 # Threshold above which we consider student were consistently populated OUT_OF_20 = "OutOf20" ABC = "ABC" NA = "N/A" level = models.ForeignKey(Level, verbose_name=_("Level")) name = models.CharField( _("Name"), max_length=30, help_text=_( "Raw name of the class. Don't write the level again. <br>Eg: A, B ... " "The level will be added to get the full name.")) slug = models.SlugField() registration_fees = models.IntegerField(_("Registration fees"), default=0) first_instalment = models.IntegerField(_("First instalment"), default=0) second_instalment = models.IntegerField(_("Second instalment"), default=0) third_instalment = models.IntegerField(_("Third instalment"), default=0) professor = models.ForeignKey(Teacher, verbose_name=_("Professor"), blank=True, null=True) leader = models.ForeignKey(Student, related_name='leaders', blank=True, null=True) subject_coefficient_list = ListField( EmbeddedModelField('SubjectCoefficient')) has_parent_reminder = models.BooleanField(default=False) has_student_reminder = models.BooleanField(default=False) mark_students = models.BooleanField( _("Mark students ?"), default=True, help_text=_( "Check if students of this classroom receive scores after " "evaluation. Uncheck if not. For example uncheck for nursery " "classrooms as they are not really marked.")) marking = models.BooleanField( _("Students marking"), default=OUT_OF_20, help_text=_("Select how we mark students in this classroom .")) class Meta: unique_together = ('level', 'name', 'school_year') ordering = ('level', 'name') permissions = (("ik_access_scores", "Can view and edit student scores"), ) def __unicode__(self): return str(self.level).decode('utf8') + ' ' + self.name def __cmp__(self, other): if self.name == other.name: return 0 return 1 if self.name > other.name else -1 def _get_size(self): return self.student_count size = property(_get_size)
class Schedule(models.Model): startDate = models.DateField() endDate = models.DateField() meetings = ListField(EmbeddedModelField("Meeting")) def __unicode__(self): return str(self.startDate) + " - " + str(self.endDate)
class HTTPDetails(models.Model): # request or response http_type = models.CharField(max_length=10) # request fields method = models.CharField(max_length=5, null=True, blank=True) uri = models.URLField(null=True, blank=True) headers = models.TextField(null=True, blank=True) version = models.FloatField(null=True, blank=True) # request part ends # response fields # header and version is here also reason = models.CharField(max_length="5", null=True, blank=True) status = models.IntegerField(null=True, blank=True) # i might need body body = models.TextField(null=True, blank=True) content_type = models.CharField(max_length=25, null=True, blank=True) content_encoding = models.CharField(max_length=25, null=True, blank=True) # response ends # i might need files also files = ListField(null=True, blank=True) file_path = models.CharField(max_length=200, null=True, blank=True) flow_details = EmbeddedModelField('FlowDetails', null=True, blank=True) #for raw_qeuries, filtering according to flow_details will be possible objects = MongoDBManager()
class DNSResponse(models.Model): type = models.IntegerField() human_readable_type = models.CharField(max_length=50) value = ListField(null=True, blank=True) flow_details = EmbeddedModelField('FlowDetails', null=True, blank=True) objects = MongoDBManager()
class Customer(AbstractWatchModel): """ Profile information for a Buyer on whatever retail website :attr:delivery_cities : List of delivery cities subsequently set by client. The last in the list is the current :attr:delivery_addresses : List of delivery addresses subsequently set by client. The last in the list is the current """ member = models.OneToOneField(Member) referrer = models.ForeignKey(Service, blank=True, null=True, related_name='+') delivery_addresses = ListField( EmbeddedModelField('shopping.DeliveryAddress')) last_payment_on = models.DateTimeField(blank=True, null=True, db_index=True) orders_count_history = ListField() items_purchased_history = ListField() turnover_history = ListField() earnings_history = ListField() total_orders_count = models.IntegerField(default=0) total_items_purchased = models.IntegerField(default=0) total_turnover = models.IntegerField(default=0) total_earnings = models.IntegerField(default=0)
class Statistic(models.Model): body = models.TextField(max_length=1024) condition = EmbeddedModelField('HealthCondition') hunch = EmbeddedModelField('Hunch') users = ListField(EmbeddedModelField('auth.User')) status = models.CharField(choices=STATUS_CHOICES, default='A', max_length=1) created_ts = models.DateTimeField(auto_now_add=True) class MongoMeta: indexes = [ [('status', -1)], [('created_ts', -1)], ] class Meta: ordering = ["-created_ts"]
class Recipe(models.Model): _DATABASE = "records" title = models.CharField(max_length=20) recipe = models.TextField() author = DictField() reviews = ListField(EmbeddedModelField('Review'))
class UserProfile(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True) regNum = models.CharField(max_length=10) branch = models.CharField(max_length=2) level = models.CharField(max_length=2) skillList = ListField(EmbeddedModelField('Skill')) phoneNo = models.CharField(max_length=11) shareNo = models.CharField(max_length=1) MOOCList = ListField() researchPaperList = ListField() aboutMe = models.CharField(max_length=100) conferenceList = ListField() profilePicture = ListField(EmbeddedModelField('profilePic')) notify = models.IntegerField(default=0) def __str__(self): return self.regNum
class Resource(models.Model): product_id = models.CharField(max_length=100, blank=True, null=True) version = models.CharField(max_length=20) # This field maps the Product Spec version provider = models.ForeignKey(Organization) content_type = models.CharField(max_length=50) download_link = models.URLField() resource_path = models.CharField(max_length=100) old_versions = ListField(EmbeddedModelField(ResourceVersion)) state = models.CharField(max_length=20) resource_type = models.CharField(max_length=100, blank=True, null=True) is_public = models.BooleanField(default=False) has_terms = models.BooleanField(default=False) meta_info = DictField() bundled_assets = ListField() def get_url(self): return self.download_link def get_uri(self): site_context = Context.objects.all()[0] base_uri = site_context.site.domain return urljoin(base_uri, 'charging/api/assetManagement/assets/' + self.pk) class Meta: app_label = 'wstore'