Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. {% extends "base.html" %}
  2. (% load widget_tweaks %}
  3.  
  4. {% block content %}
  5. <form method="post" enctype="multipart/form-data">
  6. <h4 style="margin-top: 0">Project Upload</h4>
  7. {% csrf_token %}
  8. {% for hidden in form.hidden_fields %}
  9. {{hidden}}
  10. {% endfor %}
  11.  
  12. {% for field in form.visible_fields %}
  13. <div class="form-group">
  14. <label for="{{field.id_for_label}}">{{field.label}}</label>
  15. {{field}}
  16. </div>
  17. {% endfor %}
  18.  
  19. <button type="submit">Upload</button>
  20. </form>
  21. {% endblock %}
  22.  
  23. class html(models.Model):
  24. project = models.CharField(max_length=50, blank=True)
  25. version = models.IntegerField(default=0)
  26. ecms=models.ManyToManyField(ecm, blank=True)
  27. diff = models.TextField(blank=True)
  28. PROGRAM_CHOICES = (
  29. ('Office', 'General office'),
  30. ('Residential', 'Residential'),
  31. ('Retail', 'Retail'),
  32. ('Restaurant', 'Restaurant'),
  33. ('Grocery', 'Grocery store'),
  34. ('Medilcal', 'Medilcal office'),
  35. ('Research', 'R&D or laboratory'),
  36. ('Hotel', 'Hotel'),
  37. ('Daycare', 'Daycare'),
  38. ('K-12', 'Educational,K-12'),
  39. ('Postsecondary', 'Educational,postsecondary'),
  40. ('Airport', 'Airport'),
  41. ('DataCenter','Data Center'),
  42. ('DistributionCenter','Distribution center,warehouse')
  43. )
  44. program = models.CharField(max_length=20, choices=PROGRAM_CHOICES, default='Retail')
  45. LOCATION_CHOICES = (
  46. ('Beijing', 'Beijing'),
  47. ('China', 'China'),
  48. ('Hong Kong', 'Hong Kong'),
  49. ('Japan', 'Japan'),
  50. ('Shanghai', 'Shanghai'),
  51. ('Shenzhen', 'Shenzhen'),
  52. ('Taiwan', 'Taiwan'),
  53. ('USA', 'United States')
  54. )
  55. location = models.CharField(max_length=15, choices=LOCATION_CHOICES, default="Hong Kong")
  56. CERTIFICATE_CHOICES = (
  57. ('LEED_v3', 'LEED_v3'),
  58. ('LEED_v4', 'LEED_v4'),
  59. ('BEAM+', 'BEAM+'),
  60. ('WELL', 'WELL'),
  61. ('No certificate','No certificate')
  62. )
  63. certificate = models.CharField(max_length=20, choices=CERTIFICATE_CHOICES, default='BEAM+')
  64. user = models.CharField(max_length=20, default='test')
  65. html = models.FileField(upload_to=dir_path)
  66. uploaded_at = models.DateTimeField(auto_now_add=True)
  67.  
  68. class ecm(models.Model):
  69. name = models.CharField(max_length=50, blank=True)
  70. TARGET_CHOICES = (
  71. ('Heating', 'Heating'),
  72. ('Cooling', 'Cooling'),
  73. ('Fan', 'Fan'),
  74. ('Lighting', 'Lighting'),
  75. ('Equipment', 'Equipment'),
  76. ('Renewable','Renewable Energy'),
  77. ('Hot Water','Hot Water System'),
  78. ('Others', 'Others'),
  79. )
  80. target=models.CharField(max_length=20, choices=TARGET_CHOICES, default='Others')
  81. description = models.TextField(blank=True)
  82. link=models.URLField(blank=True)
  83.  
  84. def __str__(self):
  85. return self.name
  86.  
  87. def model_form_upload(request):
  88. if request.method == 'POST':
  89. if form.is_valid():
  90. newhtml = form.save()
  91. newhtml.save()
  92. else:
  93. form = DocumentForm()
  94.  
  95. return render(request, 'model_form_upload.html', {'form': form})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement