Posted

print

favorite this post Django 1.9.7 PostgreSQL 3.6.3 (India) hide this posting unhide

compensation: Please offer a bid in $US

The Django project is called "cogswatch" and the app name is "cw".

Following are Django models for 20 PostgreSQL tables. As you can see, the inspections field in the first Model, BasicInfo, acts as a primary key and therefore is unique. In the other 19 models, the inspections field (inspections_id in SQL) acts as a FK pointing to BasicInfo. An inspection therefore consists of the following:
1) one BasicInfo object;
2) zero or more objects of each of the other 19 models;

e.g. an inspection might consist of 2 instances of two WellNameStatus objects, one WellUIC and zero instances of each of the other models, but it must have one and only on BasicInfo instance.

The object is to create the views, forms url patterns and templates to enable an inspector to enter an inspection. The transaction should begin with a form to create the BasicInfo object. When the user saves, he should be prompted to create a WellNameStatus. When saved, the WellNameStatus inspections FK should match the inspections field of the previously created BasicInfo object. The WellNameStatus save should redirect to prompt the user to either enter a second WellNameStatus or to enter a first WkvrComment, and this pattern should continue until the user has been prompted to enter zero or more of each of the 19 "spokes" of the BasicInfo "axle". Thus when the data-entry session ends, PostgreSQL would show one cw_basicinfo (cw is the Django app name) row for the inspection and zero or more rows for each of the other 19 Models.
##############################
class BasicInfo(models.Model):
##############################
# the other 19 files in the http://cogcc.state.co.us/documents/data/downloads/Field/FieldDownload.html download have a FK pointing to BasicInfo; inspection data appear in county_detail and_operator_detail (since BasicInfo has FKs for County and Operator); the other 19 files represent different aspects of an inspection; the inspection may involve more than one well, in which case there will be 2+ rows in WellNameStatus; likewise there may be 0+ rows with this inspections number in any of the other 18 tables; WellNameStatus (one of the 18) may ba added to well_detail eventually ( so if the inspection invloved 2 wells, they would both be represented in the welldetail view)
inspections = models.AutoField(primary_key=True,max_length=9,unique=True)
insp_date = models.DateField(null=True)
oper_num = models.IntegerField(default=0)
company = models.CharField(blank=True,null=True,max_length=64)
loc_id = models.IntegerField(default=0)
qtr_qtr = models.CharField(blank=True,null=True,max_length=6)
sec = models.IntegerField(default=0)
twp = models.CharField(blank=True,null=True,max_length=8)
rng = models.CharField(blank=True,null=True,max_length=8)
meridian= models.CharField(blank=True,null=True,max_length=4)
fld_code = models.CharField(blank=True,null=True,max_length=64)
field_name = models.CharField(blank=True,null=True,max_length=64)
form = models.CharField(blank=True,null=True,max_length=64)
form_status = models.CharField(blank=True,null=True,max_length=64)
#perator = models.ForeignKey(Operator, default=0, blank=False, null=False, verbose_name='Operator' )
#ounty = models.ForeignKey(County, default=0, blank=False, null=False, verbose_name='County' )
dummy = models.CharField(blank=True,null=True,max_length=64)
updated = models.DateField(auto_now_add=True)

def get_absolute_url(self):
return reverse('cw_basicinfo_detail', kwargs={'inspections': self.inspections})


###################################
class WellNameStatus(models.Model):
###################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
fac_status = models.CharField(null=True,max_length=2048)
well_type = models.CharField(null=True,max_length=2048)
cnty_code = models.IntegerField(default=0)
seq_code = models.IntegerField(default=0)
insp_status = models.CharField(null=True,max_length=2048)
fac_name = models.CharField(null=True,max_length=2048)
fac_num = models.CharField(null=True,max_length=2048)
#ell = models.ForeignKey(Well, default=0, blank=False, null=False, verbose_name='Well' )
updated = models.DateField(auto_now_add=True)

################################
class WkvrComment(models.Model):
################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
wkvr_comment = models.CharField(null=True,max_length=2048)
updated = models.DateField(auto_now_add=True)


############################
class WellUIC(models.Model):
############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
uic_vio = models.CharField(null=True,max_length=64)
tbg_inj_press = models.IntegerField(default=0)
tbg_csg_annulus = models.IntegerField(default=0)
last_mit = models.DateField(null=True)
inj_type = models.CharField(null=True,max_length=64)
test = models.CharField(null=True,max_length=64)
tbg_press = models.IntegerField(default=0)
csg_press = models.IntegerField(default=0)
brdn_press = models.IntegerField(default=0)
insp_comm = models.IntegerField(default=0)
mit_comm = models.IntegerField(default=0)
updated = models.DateField(auto_now_add=True)


####################################
class WellStimulation(models.Model):
####################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
stim_type = models.CharField(null=True,max_length=64)
stim_type_other = models.CharField(null=True,max_length=64)
max_csg_press = models.IntegerField(default=0)
tbg_press = models.IntegerField(default=0)
sur_csg_press = models.IntegerField(default=0)
int_csg_press = models.IntegerField(default=0)
prod_csg_press = models.IntegerField(default=0)
bradenhead = models.IntegerField(default=0)
flwbk_fluid = models.BooleanField(default=False)
gas_fluid = models.BooleanField(default=False)
updated = models.DateField(auto_now_add=True)


#############################
class WellIdle(models.Model):
#############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
well_status = models.CharField(null=True,max_length=64)
comment = models.CharField(null=True,max_length=2048)
corr_act = models.CharField(null=True,max_length=2048)
corr_date = models.DateField(null=True)
insp_status = models.CharField(null=True,max_length=64)
updated = models.DateField(auto_now_add=True)

####################################
class WellProdComment(models.Model):
####################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
comment = models.CharField(null=True,max_length=2048)
updated = models.DateField(auto_now_add=True)


##############################
class WellDrill(models.Model):
##############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
prmt_post = models.CharField(null=True,max_length=64)
sign = models.CharField(null=True,max_length=64)
bop_pipe = models.CharField(null=True,max_length=64)
bop_blind = models.CharField(null=True,max_length=64)
bop_hydril = models.CharField(null=True,max_length=64)
bop_test = models.CharField(null=True,max_length=64)
pressure = models.IntegerField(default=0)
pit_lined = models.BooleanField(default=False)
pit_unlied = models.BooleanField(default=False)
close_loop = models.BooleanField(default=False)
part_close_loop = models.BooleanField(default=False)
multi_well_pad = models.BooleanField(default=False)
cutting_disp_loc = models.CharField(null=True,max_length=2048)
comment = models.CharField(null=True,max_length=2048)
updated = models.DateField(auto_now_add=True)

###############################
class WellCement(models.Model):
###############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
sur_cmt = models.CharField(null=True,max_length=64)
inter_casing_vol = models.CharField(null=True,max_length=64)
prod_casing_vol = models.CharField(null=True,max_length=64)
plug_depth = models.IntegerField(default=0)
plug_vol = models.IntegerField(default=0)
comment = models.CharField(null=True,max_length=2048)
updated = models.DateField(auto_now_add=True)

###################################
class WellBradenhead(models.Model):
###################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
comment = models.CharField(null=True,max_length=2048)
corr_act = models.CharField(null=True,max_length=2048)
corr_date = models.DateField(null=True)
updated = models.DateField(auto_now_add=True)

###############################
class WasteMngmt(models.Model):
###############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
e_p_waste = models.CharField(null=True,max_length=2048)
mngmt_method = models.CharField(null=True,max_length=2048)
status = models.CharField(null=True,max_length=64)
comment = models.CharField(null=True,max_length=2048)
updated = models.DateField(auto_now_add=True)

#############################
class TankBerm(models.Model):
#############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
comtact = models.CharField(null=True,max_length=64)
num_tanks = models.IntegerField(default=0)
cap = models.CharField(null=True,max_length=64)
tank_const_mat = models.CharField(null=True,max_length=64)
cont_other = models.CharField(null=True,max_length=64)
cap_other = models.CharField(null=True,max_length=64)
const_mat_other = models.CharField(null=True,max_length=64)
berm_mat = models.CharField(null=True,max_length=64)
status_berm_cap = models.CharField(null=True,max_length=64)
status = models.CharField(null=True,max_length=64)
updated = models.DateField(auto_now_add=True)

###############################
class StormWater(models.Model):
###############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
location_bmps = models.CharField(null=True,max_length=64)
bmp_status = models.CharField(null=True,max_length=64)
lease_road_bmps = models.CharField(null=True,max_length=64)
lease_road_bmp_status = models.CharField(null=True,max_length=64)
materials_bmps = models.CharField(null=True,max_length=64)
materials_road_bmp_status = models.CharField(null=True,max_length=64)
comments_by_detail = models.CharField(null=True,max_length=2048)
overall_comment = models.CharField(null=True,max_length=2048)
overall_status = models.CharField(null=True,max_length=2048)
corr_act = models.CharField(null=True,max_length=2048)
corr_date = models.DateField(null=True)
updated = models.DateField(auto_now_add=True)

###########################
class Spills(models.Model):
###########################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
description = models.CharField(null=True,max_length=64)
location_of_spill = models.CharField(null=True,max_length=64)
corr_act = models.CharField(null=True,max_length=2048)
corr_date = models.DateField(null=True)
updated = models.DateField(auto_now_add=True)


######################################
class ReclamationDetail(models.Model):
######################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
land_use_current = models.CharField(null=True,max_length=64)
pit_closed = models.CharField(null=True,max_length=64)
veg_unused_area = models.CharField(null=True,max_length=64)
prod_area_stable = models.CharField(null=True,max_length=64)
seg_soil_replace = models.CharField(null=True,max_length=64)
inter_comment = models.CharField(null=True,max_length=64)
land_use_final = models.CharField(null=True,max_length=64)
well_plug = models.CharField(null=True,max_length=64)
backfill_pit = models.CharField(null=True,max_length=64)
reclaim_final = models.CharField(null=True,max_length=64)
recontoured = models.CharField(null=True,max_length=64)
veg_80_percent = models.CharField(null=True,max_length=64)
veg_perenial = models.CharField(null=True,max_length=64) #(SIC)
weeds_present = models.CharField(null=True,max_length=64) #(SIC)
subsidence = models.CharField(null=True,max_length=64) #(SIC)
final_comment = models.CharField(null=True,max_length=2048)
land_use_inter_comment = models.CharField(null=True,max_length=2048)
land_use_final_comment = models.CharField(null=True,max_length=2048)
nox_weeds = models.CharField(null=True,max_length=64)
interim_overall = models.CharField(null=True,max_length=2048)
final_overall = models.CharField(null=True,max_length=2048)
never_built = models.CharField(null=True,max_length=64)
crop_topsoil_replace = models.CharField(null=True,max_length=64)
recontour_cropland = models.CharField(null=True,max_length=64)
crop_forage_establish = models.CharField(null=True,max_length=64)
non_crop_topsoil_replace = models.CharField(null=True,max_length=64)
non_cropland_recontour = models.CharField(null=True,max_length=64)
non_cropland_veg_80_per = models.CharField(null=True,max_length=64)
to_be_added = models.CharField(null=True,max_length=64)
to_be_added_date = models.DateField(null=True)
final_corr_act = models.CharField(null=True,max_length=2048)
final_corr_date = models.DateField(null=True)
well_release_act_loc = models.CharField(null=True,max_length=64)
updated = models.DateField(auto_now_add=True)

def __get_label(self, field):
return text_type(self._meta.get_field(field).verbose_name)


##############################
class PitDetail(models.Model):
##############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
type = models.CharField(null=True,max_length=2048)
lined = models.CharField(null=True,max_length=2048)
status = models.CharField(null=True,max_length=2048)
pit_comm = models.CharField(null=True,max_length=2048)
pit_ca = models.CharField(null=True,max_length=2048)
pit_corr_date = models.DateField(null=True)
idnum = models.IntegerField(default=0)
updated = models.DateField(auto_now_add=True)


##############################
class LocDetail(models.Model):
##############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
loc_detail = models.CharField(blank=True,null=True,max_length=2048)
status = models.CharField(blank=True,null=True,max_length=2048)
comment = models.CharField(blank=True,null=True,max_length=2048)
equip_num = models.IntegerField(default=0)
corr_act = models.CharField(blank=True,null=True,max_length=2048)
corr_date = models.DateField(null=True)
updated = models.DateField(auto_now_add=True)

def get_absolute_url(self):
return reverse('cw_locdetail_detail', kwargs={'inspections': self.inspections})

##################################
class Environmental(models.Model):
##################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
est_spill_vol = models.IntegerField(default=0)
type = models.CharField(null=True,max_length=64)
description = models.CharField(null=True,max_length=2048)
comments = models.CharField(null=True,max_length=2048)
corr_act = models.CharField(null=True,max_length=2048)
corr_date = models.DateField(null=True)
updated = models.DateField(auto_now_add=True)

#####################################
class CorrectiveAction(models.Model):
#####################################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
loc_detail = models.CharField(null=True,max_length=2048)
status = models.CharField(null=True,max_length=2048)
comment = models.CharField(null=True,max_length=2048)
corr_act = models.CharField(null=True,max_length=2048)
corr_date = models.DateField(null=True)
updated = models.DateField(auto_now_add=True)

###############################
class Complaint2(models.Model):
###############################
inspections = models.ForeignKey(BasicInfo, default=0, blank=False, null=False, verbose_name='BasicInfo' )
comment = models.CharField(null=True,max_length=4096)
updated = models.DateField(auto_now_add=True)


  • do NOT contact me with unsolicited services or offers

post id: 6842307265

posted:

best of [?]