Commits

Udi Bauman committed 6c99c66

Added inline editing of allocations

Comments (0)

Files changed (2)

django_ultrasound/events/admin.py

     list_display = ["constraintDiscriptions", "constrainMethode" ]
 admin.site.register(Constraint,ConstraintAdmin)
 
-class AllocationAdmin(admin.ModelAdmin):
-    list_display = ["allocation_event","allocation_product","quantity_allocation","quantity_use","employee_get_allocation","allocation_price"]
-    list_filter = ["allocation_event","allocation_product","quantity_allocation","quantity_use","employee_get_allocation","allocation_price"]
-admin.site.register(Allocation,AllocationAdmin)    
+class AllocationAdmin(admin.TabularInline):
+    model = Allocation
+    extra = 5
 
 class EventAdmin(admin.ModelAdmin):
     list_display = ["description",
                     "start_houre",
                     "end_houre",
                     "location",
-                    "logo",
+                    "logo_image",
                     "employee_in_charge",
                     "marketing_employee",
                     "constrain"]
-    list_filter = ["event_year",
-                   "type",
+    inlines = [AllocationAdmin,]
+    
+#    list_filter = ["event_year",
+#                   "type",
+#                   "location",
+#                   "employee_in_charge",
+#                   "marketing_employee"]
+    list_filter = ["type",
                    "location",
                    "employee_in_charge",
                    "marketing_employee"]
     
+    def logo_image(self, obj):
+        return "<img src='%s'>" % obj.logo
+
+    logo_image.allow_tags = True
+    
 admin.site.register(Event,EventAdmin)
 

django_ultrasound/events/models.py

     event_day = models.PositiveIntegerField(_("day"), help_text=_("Enter Day"),blank=True)
     end_houre = models.DateTimeField(_("end event"), auto_now=True)
     location = models.ForeignKey(Location,verbose_name = _("location of the event"))
-    logo = models.URLField(_("the address of the loge of the event"))
+    logo = models.URLField(_("the address of the loge of the event"), verify_exists=False)
     employee_in_charge = models.ForeignKey(Employee, verbose_name= _("the employee in charge"),related_name="employee2",null=True, blank=True)
-    marketing_employee = models.ForeignKey(Employee, verbose_name= _("the employee in charge"),related_name="employee3",null=True, blank=True)
+    marketing_employee = models.ForeignKey(Employee, verbose_name= _("marketing employee"),related_name="employee3",null=True, blank=True)
     constrain = models.ForeignKey(Constraint,verbose_name= _("the constrain of this event"))
 
 class Allocation(models.Model):
     allocation_event = models.ForeignKey(Event,verbose_name= _("the event that has allocation "),related_name="employee4",null=True, blank=True)
     allocation_product = models.ForeignKey(Product,verbose_name= _("the products that as allocated"),related_name="employee5",null=True, blank=True)
     quantity_allocation = models.PositiveIntegerField(_("the quantity that was alloceted"))
-    quantity_use = models.PositiveIntegerField(_("the quantity that was alloceted"))
+    quantity_use = models.PositiveIntegerField(_("the quantity that was already used"), editable=False, default=0)
     employee_get_allocation = models.ForeignKey(Employee,verbose_name= _("the employee in charge"),related_name="employee1")
     allocation_price = models.PositiveIntegerField(_("the price of the product that was alloceted"))