SHARE
TWEET

Untitled

a guest Jun 26th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PresalesForm(forms.Form):
  2.     class Meta:
  3.         model = Presales
  4.         fields = ('selected_opportunity', 'task_description', 'hours', 'selected_engineer_level', 'total_cost')
  5.      
  6. def presales(request):
  7.     my_opportunities = cwObj.get_opportunities()
  8.  
  9.     PresalesFormSet = formset_factory(PresalesForm, extra=1)
  10.  
  11.     if request.method == 'POST':
  12.         presales_formset = PresalesFormSet(request.POST)
  13.  
  14.         if presales_formset.is_valid():
  15.  
  16.             for presales_form in presales_formset:
  17.                 selected_opportunity = request.POST.get('selected_opportunity')
  18.                 task_description = request.POST.get('task_description')
  19.                 hours = request.POST.get('hours')
  20.                 select_engineer_level = request.POST.get('select_engineer_level')
  21.  
  22.             else:
  23.                 presales_formset = PresalesFormSet(initial="None")
  24.  
  25.                 context = {'presales_formset': presales_formset, 'my_opportunities': my_opportunities}
  26.  
  27.             return render(request, 'website/presales.html', context)
  28.      
  29. <form action="{% url 'presales' %}" method="post" name="presalesForm" id="presalesForm" data-total-url="{% url 'presales_total' %}">
  30.                 {% csrf_token %}
  31.  
  32.                 {{ presales_formset.management_form }}
  33.  
  34.                 {% for presales_form in presales_formset %}
  35.                 <div class="field">
  36.                     <label class="label is-large">Create Task</label>
  37.                 </div>
  38.                 <div class="section">
  39.                     <div class="field">
  40.                         <label class="label">Opportunity</label>
  41.                         <div class="select">
  42.                             <select name="select_opportunity" id="select_opportunity">
  43.                                 <option value="">Opportunity</option>
  44.                                 {% for opportunity in my_opportunities %}
  45.                                 <option name="selected_opportunity" id="selected_opportunity" value="{{ opportunity.name }}">{{ opportunity.name }}</option>
  46.                                 {% endfor %}
  47.                             </select>
  48.                         </div>
  49.                     </div>
  50.                     <label class="label">Task Description:</label>
  51.                     <div class="field">
  52.                         <div class="control">
  53.                             <input class="input" name="task_description" id="task_description" placeholder="Task Description">
  54.                         </div>
  55.                     </div>
  56.                     <label class="label">Hours</label>
  57.                     <div class="field">
  58.                         <div class="control">
  59.                             <input class="input" name="hours" id="hours" placeholder="Hours">
  60.                         </div>
  61.                     </div>
  62.                     <label class="label">Engineer Level:</label>
  63.                     <div class="field">
  64.                         <div class="select">
  65.                             <select name="select_engineer_level" id="select_engineer_level">
  66.                                 <option value="">Engineer Level</option>
  67.                                 <option value="PM">PM</option>
  68.                                 <option value="Solutions Technician">Solutions Technician</option>
  69.                                 <option value="Solutions Engineer">Solutions Engineer</option>
  70.                                 <option value="Senior Solutions Engineer">Senior Solutions Engineer</option>
  71.                                 <option value="Solutions Architect">Solutions Architect</option>
  72.                             </select>
  73.                         </div>
  74.                     </div>
  75.                 </div>
  76.                 <div class="field">
  77.                     <div class="control">
  78.                         <button class="button is-info" type="button">Add Task</button>
  79.                     </div>
  80.                 </div>
  81.                 {% endfor %}
  82.                 <span class="label is-medium is-pulled-right" id="total_cost">Total: {{ total }}</span>
  83.             </form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top