Commits

Denis Darii committed 6e8ab57

added admin and models files

  • Participants
  • Parent commits 16ef6b4

Comments (0)

Files changed (4)

File bisnavi/admin.py

+from django.contrib import admin
+from bisnavi.models import Photo
+from bisnavi.models import MenuItem
+
+
+class PhotoAdmin(admin.ModelAdmin):
+    pass
+admin.site.register(Photo, PhotoAdmin)
+
+
+class MenuItemAdmin(admin.ModelAdmin):
+    pass
+admin.site.register(MenuItem, MenuItemAdmin)

File bisnavi/models.py

+import os
+import time
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+
+def get_image_path(instance, filename):
+    upload_path = time.strftime('bisnavi/%Y/%m/%d')
+
+    return os.path.join(upload_path, filename)
+
+
+class Photo(models.Model):
+    title = models.CharField(max_length=75)
+    image = models.ImageField(upload_to=get_image_path)
+    order = models.IntegerField(default=1, help_text=_('1 is the first displayed.'))
+    url = models.URLField(blank=True)
+    first_line_text = models.CharField(max_length=250, blank=True, null=True)
+    second_line_text = models.CharField(max_length=250, blank=True, null=True)
+
+    class Meta:
+        verbose_name = _('Photo')
+        verbose_name_plural = _('Photos')
+        ordering = ('order',)
+
+    def __unicode__(self):
+        return unicode(self.title)
+
+
+class MenuItem(models.Model):
+    text = models.CharField(max_length=75)
+    url = models.URLField(blank=True)
+
+    class Meta:
+        verbose_name = _('Menu item')
+        verbose_name_plural = _('Menu items')
+        ordering = ('text',)
+
+    def __unicode__(self):
+        return unicode(self.text)

File bisnavi/tests.py

+# To do...

File bisnavi/views.py

+# Leaved empty