Odevzdávátko: Nezadané problémy nelze odevzdat
This commit is contained in:
		
							parent
							
								
									92cb8ec206
								
							
						
					
					
						commit
						512f14ed4d
					
				
					 2 changed files with 23 additions and 0 deletions
				
			
		|  | @ -89,6 +89,13 @@ class NahrajReseniForm(forms.ModelForm): | ||||||
| 		if 'problem' in self.fields: | 		if 'problem' in self.fields: | ||||||
| 			self.fields['problem'].label = "Všechny řešené problémy" | 			self.fields['problem'].label = "Všechny řešené problémy" | ||||||
| 
 | 
 | ||||||
|  | 	def clean_problem(self): | ||||||
|  | 		problem = self.cleaned_data.get('problem') | ||||||
|  | 		for p in problem: | ||||||
|  | 			if p.stav != m.Problem.STAV_ZADANY: | ||||||
|  | 				raise forms.ValidationError("Problém " + str(p) + " již nelze řešit!") | ||||||
|  | 		return problem | ||||||
|  | 
 | ||||||
| ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni,  | ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni,  | ||||||
| 		form = NahrajReseniForm, | 		form = NahrajReseniForm, | ||||||
| 		fields = ('soubor','res_poznamka'), | 		fields = ('soubor','res_poznamka'), | ||||||
|  |  | ||||||
|  | @ -30,6 +30,13 @@ | ||||||
|         {{ field }} |         {{ field }} | ||||||
|       </td> |       </td> | ||||||
|     </tr> |     </tr> | ||||||
|  | 
 | ||||||
|  |     {% if field.errors %} | ||||||
|  |       <tr> | ||||||
|  |         <td colspan="2"><span class="field-error">{{ field.errors }}</span></td> | ||||||
|  |       </tr> | ||||||
|  |     {% endif %} | ||||||
|  | 
 | ||||||
|     {% endwith %} |     {% endwith %} | ||||||
|   </table> |   </table> | ||||||
| 
 | 
 | ||||||
|  | @ -54,6 +61,13 @@ | ||||||
|           {{ field }} |           {{ field }} | ||||||
|         </td> |         </td> | ||||||
|       </tr> |       </tr> | ||||||
|  | 
 | ||||||
|  |       {% if field.errors %} | ||||||
|  |         <tr> | ||||||
|  |           <td colspan="2"><span class="field-error">{{ field.errors }}</span></td> | ||||||
|  |         </tr> | ||||||
|  |       {% endif %} | ||||||
|  | 
 | ||||||
|     {% endwith %} |     {% endwith %} | ||||||
|   </table> |   </table> | ||||||
| 
 | 
 | ||||||
|  | @ -61,6 +75,8 @@ | ||||||
| 
 | 
 | ||||||
| {% include "odevzdavatko/prilohy.html" %} | {% include "odevzdavatko/prilohy.html" %} | ||||||
| 
 | 
 | ||||||
|  | {{form.non_field_errors}} | ||||||
|  | 
 | ||||||
| <hr> | <hr> | ||||||
| <h4>Odevzdat řešení</h4> | <h4>Odevzdat řešení</h4> | ||||||
| <input type="submit" value="Odevzdat"> | <input type="submit" value="Odevzdat"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue