class Inventory(models.Model): code = models.CharField(max_length=10) name = models.CharField(max_length=50) price = models.IntegerField()
class Author(models.Model): name = models.CharField(max_length=200) def __str__(self): return self.name
class Position(models.Model): position_held = models.CharField(max_length=200, blank=True) year_in_college = models.IntegerField(blank=True) duration = models.CharField(max_length=100, blank=True) description = models.CharField(max_length=1000, blank=True)
class Locations(models.Model): name = models.CharField(max_length=200, null=True) fendering_position = models.CharField(max_length=1000, null=True, blank=True) Cargos_permitted = MultiSelectField(choices=Cargoes_Permitted, max_choices=5, max_length=1000, null=True, blank=True) Type_of_operation = models.CharField(max_length=1000, null=True, blank=True) Depth_of_water = models.CharField(max_length=1000, null=True, blank=True) Approval_to_conduct_STS_issued_by = models.CharField(max_length=1000, null=True, blank=True) Approval_needed_prior_to_each_STS_operation = models.CharField( max_length=1000, null=True, blank=True) Vessel_sizes_permitted = models.CharField(max_length=1000, null=True, blank=True) Night_time_berthing_permitted = models.CharField(max_length=1000, null=True, blank=True) Is_local_piloting_assistance_required = models.CharField(max_length=1000, choices=[('Yes', 'Yes'), ('No', 'No')], null=True, blank=True) Local_piloting_additional_information = models.CharField(max_length=1000, null=True, blank=True) Are_tugs_required = models.CharField(max_length=1000, null=True, blank=True) date_created = models.DateTimeField(auto_now_add=True, null=True) locations_pic = models.ImageField(null=True, blank=True) def __str__(self): return self.name
class Competition(models.Model): title = models.CharField(max_length=200, blank=True) level = models.CharField(max_length=200, blank=True) rank = models.CharField(max_length=200, blank=True) date = models.CharField(max_length=200, blank=True) issuing_auth = models.CharField(max_length=200, blank=True)
class CollegeCourse(models.Model): name = models.CharField(max_length=200, blank=True) description = models.CharField(max_length=1000, blank=True)
class Entry(models.Model): blog = models.EmbeddedModelField( model_container=Blog, ) headline = models.CharField(max_length=255)
class Certification(models.Model): name = models.CharField(max_length=200, blank=True) issue_date = models.CharField(max_length=200, blank=True) valid_till = models.CharField(max_length=200, blank=True) description = models.CharField(max_length=1000, blank=True) issuing_auth = models.CharField(max_length=200, blank=True)
class TransactionBinanceTFUELUSDT(models.Model): _id = models.ObjectIdField() e = models.CharField(verbose_name='거래소명', max_length=15) cu = models.CharField(verbose_name='화폐', max_length=10) f = models.CharField(verbose_name='기축화폐', max_length=10) id = models.IntegerField(verbose_name='체결id') is_ask = models.IntegerField(verbose_name='매도매수여부') p = models.FloatField(verbose_name='체결가') v = models.FloatField(verbose_name='거래량') t = models.IntegerField(verbose_name='타임스탬프') objects = models.DjongoManager() class Meta: verbose_name = verbose_name_plural = 'TransactionBinanceTFUELUSDT' indexes = [ models.Index(fields=['t'], name='timestamp'), models.Index(fields=['e', 'cu', 'f'], name='exch_curr_fiat') ] unique_together = ('e', 'cu', 'f', 't') ordering = ['-t'] def __str__(self): return f'{self.e}/{self.cu}_{self.f} ({self.t})' @classmethod def upsert(cls, e, cu, f, transaction): return cls.objects.mongo_update( { 'e': e.lower(), 'cu': cu.lower(), 'f': f.lower(), 't': transaction['t'] }, { '$set': dict(e=e.lower(), cu=cu.lower(), f=f.lower(), **transaction) }, upsert=True) @classmethod def bulk_upsert(cls, e, cu, f, Transactions): operations = [ UpdateOne( { 'e': e.lower(), 'cu': cu.lower(), 'f': f.lower(), 't': transaction['t'] }, { '$set': dict( e=e.lower(), cu=cu.lower(), f=f.lower(), **transaction) }, upsert=True) for transaction in Transactions ] return cls.objects.mongo_bulk_write(operations, ordered=False) @classmethod def latest(cls, e, cu, f): now_date = now() t = int(now_date.timestamp()) # aligned_t = int(align_date(now_date, i).timestamp()) try: prev_candle = cls.objects.filter(e=e, cu=cu, f=f).first() open_price = prev_candle.c except: open_price = 0 return cls(e=e, cu=cu, f=f, **Transaction.objects.aggregate(exchange=e, currency=cu, fiat=f, from_ts=aligned_t, until_ts=t, open_price=open_price))
class Hk(models.Model): code = models.CharField('Stock Code', max_length=20, primary_key=True) data = models.JSONField('Data', null=True) def __str__(self): return self.code
class Doctor(models.Model): doc_name = models.CharField(max_length=100) doc_id = models.CharField(max_length=50) hos_id = models.CharField(max_length=30) doc_mob_no = models.CharField(max_length=12) doc_address = models.CharField(max_length=500) doc_age = models.CharField(max_length=2) doc_email = models.CharField(max_length=40) doc_lic_no = models.CharField(max_length=100) doc_admin_id = models.CharField(max_length=50) doc_patient_id = models.CharField(max_length=100) doc_sex = models.CharField(max_length=10) doc_design = models.CharField(max_length=50) doc_exp = models.CharField(max_length=4) def __str__(self): return self.doc_name + ' - ' + self.doc_id
class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def __str__(self): return self.name
class Orders(models.Model): order_id = models.AutoField(primary_key=True) items_json = models.CharField(max_length=5000) name = models.CharField(max_length=90) email = models.CharField(max_length=111) address = models.CharField(max_length=111) city = models.CharField(max_length=111) state = models.CharField(max_length=111) zip_code = models.CharField(max_length=111) phone = models.CharField(max_length=111, default="") amount = models.IntegerField(default=0) razorpayid = models.CharField(max_length=255, default="") razorpaypaymentid = models.CharField(max_length=255, default="") razorpaysignature = models.CharField(max_length=255, default="")
class PoR(models.Model): place = models.CharField(max_length=200, blank=True) positions = models.ArrayField(model_container=Position, blank=True)
class ReportForm(models.Model): subject = models.CharField(max_length=30) reported_user = models.CharField(max_length=30) description = models.CharField(max_length=200) image = models.ImageField(upload_to='', null=True, blank=True)
class OnlineCourse(models.Model): name = models.CharField(max_length=200, blank=True) company = models.CharField(max_length=200, blank=True) partner_insti = models.CharField(max_length=200, blank=True) description = models.CharField(max_length=1000, blank=True)
class MatchModel(models.Model): activity_name = models.CharField(max_length=100) class Meta: abstract = True
class Patent(models.Model): title = models.CharField(max_length=200, blank=True) description = models.CharField(max_length=1000, blank=True) date = models.CharField(max_length=200, blank=True) link = models.CharField(max_length=300, blank=True)
class ArrayBlog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() class Meta: abstract = True
class Place(models.Model): name = models.CharField(max_length=200, blank=True)
class TemplateMetadata(djongo_models.Model): key = djongo_models.CharField(max_length=50) value_data_type = djongo_models.CharField(max_length=50) class Meta: abstract = True
class SelfProject(models.Model): title = models.CharField(max_length=200, blank=True) from_date = models.CharField(max_length=200, blank=True) to_date = models.CharField(max_length=200, blank=True) description = models.CharField(max_length=1000, blank=True)
class InfoTeacher(models.Model): fullname = models.CharField(max_length=100) email = models.EmailField(max_length=100, blank=True) class Meta: abstract = True
class Support_Craft_Details(models.Model): Vessel_Name = models.CharField(max_length=1000, null=True, blank=True) Support_Craft_Owner = models.CharField(max_length=1000, null=True, blank=True) Telephone = models.CharField(max_length=1000, null=True, blank=True)
class Account(models.Model): _id = models.ObjectIdField(primary_key=True) name = models.CharField(max_length=100, unique=True) role = models.ForeignKey(Role, on_delete=models.CASCADE) image = models.ImageField(default=MEDIA_ROOT, upload_to='account/%Y/%m/%d/') password = models.CharField(max_length=450) info = models.EmbeddedModelField(model_container=InfoTeacher, model_form_class=InfoTeacherForm, blank=True) createdate = models.DateTimeField(default=timezone.now, editable=True) status = models.BooleanField(default=True) objects = models.DjongoManager() def __str__(self): return u'%s' % self.name def __iter__(self): return self def save(self, *args, **kwargs): for field_name in ['password']: val = getattr(self, field_name, False) if val: enc_password = pwd_context.hash(val) setattr(self, field_name, enc_password) super(Account, self).save(*args, **kwargs) def delete(self, *args, **kwargs): for field_name in ['pk']: val = getattr(self, field_name, False) if val: account = Account.objects.filter(pk=val).first() storage, path = account.image.storage, account.image.path storage.delete(path) super(Account, self).delete(*args, **kwargs) def deleteimage(self, *args, **kwargs): for field_name in ['pk']: val = getattr(self, field_name, False) if val: account = Account.objects.filter(pk=val).first() storage, path = account.image.storage, account.image.path storage.delete(path) def saveupdate(self, *args, **kwargs): super(Account, self).save(*args, **kwargs) def getall(self): return { "id": str(self._id), "name": self.name, "rolename": self.role.name, "roleid": str(self.role._id), "image": self.image.url, "infofullname": self.info.fullname, "infoname": self.info.email, "createdate": str(self.createdate), "status": self.status } def verify_password(self, raw_password): return pwd_context.verify(raw_password, self.password)
class Area_Details(models.Model): Location_under_the_control_of_authorities = models.CharField( max_length=1000, null=True, blank=True) Current_port_security_level = models.CharField(max_length=1000, null=True, blank=True) What_is_considered_port_limits = models.CharField(max_length=1000, null=True, blank=True) What_is_considered_international_waters = models.CharField(max_length=1000, null=True, blank=True) Distance_from_support_base = models.CharField(max_length=1000, null=True, blank=True) Transit_time_from_shore_to_STS_location = models.CharField(max_length=1000, null=True, blank=True) Size_of_transfer_area = models.CharField(max_length=1000, null=True, blank=True) Does_the_area_have_a_large_enough_run_in_area = models.CharField( max_length=1000, null=True, blank=True) Is_the_transfer_area_sheltered = models.CharField(max_length=1000, null=True, blank=True) Regulations_to_be_complied_during_the_operation = models.CharField( max_length=1000, null=True, blank=True) Nature_of_seabed = models.CharField(max_length=1000, null=True, blank=True) Average_depth_of_water = models.CharField(max_length=1000, null=True, blank=True) STS_location_suitable_for_anchoring = models.CharField(max_length=1000, null=True, blank=True) Any_other_service_provider_in_the_same_vicinity = models.CharField( max_length=1000, null=True, blank=True)
class Issue(models.Model): _id = models.ObjectIdField() number = models.PositiveIntegerField(null=False) repo = models.ForeignKey("project.Repository", on_delete=models.CASCADE) project = models.ForeignKey("project.Project", on_delete=models.CASCADE) title = models.CharField(max_length=100) type = models.CharField(max_length=16, choices=ISSUE_TYPES, blank=True) labels = models.CharField(max_length=255, blank=True) invalid = models.BooleanField(default=False) # author = models.CharField(max_length=64, blank=True) service = models.CharField(max_length=16, choices=CLASSES_OF_SERVICE, blank=True) timeline = models.ArrayField(model_container=Event, blank=True) done = models.BooleanField(default=False, blank=True) created_at = models.DateTimeField(blank=True) updated_at = models.DateTimeField(blank=True) # Kanban stuff kanban_start_date = models.DateTimeField(blank=True) kanban_end_date = models.DateTimeField(blank=True) kanban_lead_time = models.PositiveIntegerField(blank=True) kanban_total_hold_time = models.PositiveIntegerField(blank=True) kanban_total_blocked_time = models.PositiveIntegerField(blank=True) kanban_metrics = models.DictField(default=dict) objects = models.DjongoManager() class Meta: # We can have the same issue on different projects unique_together = (("repo", "number", "project"), ) @cached_property def github(self): return get_github_issue(self.repo.identifier, self.number) @property def github_url(self): return format_html( "<a href='https://github.com/{path}' target=_blank>{path}</a>", path= f"{self.repo.organization}/{self.repo.code}/issues/{self.number}", ) @property def github_labels(self): return [l.name.lower() for l in self.github.labels] @cached_property def github_timeline(self): events = [] project_id = self.project.github_id for event in get_github_issue_timeline(self.github): project_card = event.raw_data.get("project_card", {}) label = event.raw_data.get("label", {}) if event.event in EVENT_LABEL_MAPPING and label.get("name") in ( "hold", "blocked", ): events.append( Event( type=EVENT_LABEL_MAPPING[event.event][label["name"]], date=as_utc(event.created_at), )) elif project_card and project_card["project_id"] == project_id: # Exclude "remove from project" for now if event.event not in TIMELINE_CARD_EVENT_TYPES: continue events.append( Event( type="moved", column=project_card["column_name"], date=as_utc(event.created_at), )) return events def get_service_type(self): if "critical" in self.github_labels: return "expedite" return "standard" def __str__(self): return f"{self.repo.code}/{self.number} - {self.title}" def _col(self, name): for column in self.project.columns: if column.code == name: return column # This might break something, but oh well return None @cached_property def _last_col_for_project(self): for column in self.project.columns[::-1]: if column.valid_wip: return column return None def process_timeline_data(self): # data = {column.code: {} for column in self.project.columns} # data["blocked"] = 0 # data["on_hold"] = 0 blocked_since = None on_hold_since = None start_date = None end_date = None lead_time = None blocked = 0 on_hold = 0 # current_column = None for event in self.github_timeline: if event.type == "on_hold": on_hold_since = event.date elif event.type == "blocked": blocked_since = event.date elif on_hold_since and event.type == "on_hold_removed": # Ignore on hold for less than 2 hours on_hold_time = on_hold_since - event.date on_hold_since = None if on_hold_time.seconds > 7200: on_hold += max(on_hold_time.days, 1) elif blocked_since and event.type == "blocked_removed": # Ignore block if less than 2 hours blocked_time = blocked_since - event.date blocked_since = None if blocked_time.seconds > 7200: blocked += max(blocked_time.days, 1) elif event.type == "moved": column = self._col(event.column) if start_date is None and column.valid_wip: start_date = event.date if column.code == self._last_col_for_project.code: end_date = event.date lead_time = max((end_date - start_date).days, 1) # TODO: Handle time in each column return { "kanban_start_date": start_date, "kanban_end_date": end_date, "kanban_lead_time": lead_time, "on_hold": on_hold, "blocked": blocked, } def save(self, *args, **kwargs): self.title = self.github.title self.labels = " | ".join(self.github_labels) # Find the first valid issue type for label in self.github_labels: if label in ISSUE_TYPE_LABEL_MAPPING: self.type = ISSUE_TYPE_LABEL_MAPPING[label] break else: self.type = "feature" self.service = self.get_service_type() self.created_at = as_utc(self.github.created_at) self.updated_at = as_utc(self.github.updated_at) self.timeline = self.github_timeline self.invalid = bool( set(self.github_labels) & set(INVALID_ISSUE_LABELS)) data = self.process_timeline_data() self.done = data["kanban_lead_time"] is not None self.kanban_start_date = data["kanban_start_date"] self.kanban_end_date = data["kanban_end_date"] self.kanban_lead_time = data["kanban_lead_time"] self.kanban_total_hold_time = data["on_hold"] self.kanban_total_blocked_time = data["blocked"] super().save(*args, **kwargs)