parent
8cb4c03998
commit
34808371a1
8 changed files with 75 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||||
|
from django.contrib import admin |
||||||
|
from .models import * |
||||||
|
|
||||||
|
# Register your models here. |
||||||
|
|
||||||
|
class SubscriberAdmin(admin.ModelAdmin): |
||||||
|
|
||||||
|
list_display = [field.name for field in Subscriber._meta.fields] |
||||||
|
list_filter = ['name'] |
||||||
|
search_fields = ['name', 'email'] |
||||||
|
|
||||||
|
class Meta: |
||||||
|
model = Subscriber |
||||||
|
|
||||||
|
admin.site.register(Subscriber, SubscriberAdmin) |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
from django.apps import AppConfig |
||||||
|
|
||||||
|
|
||||||
|
class LandingConfig(AppConfig): |
||||||
|
name = 'flatpages_ext' |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
from django import forms |
||||||
|
from .models import * |
||||||
|
|
||||||
|
class SubscriberForm(forms.ModelForm): |
||||||
|
|
||||||
|
class Meta: |
||||||
|
model = Subscriber |
||||||
|
exclude = [""] |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
from django.db import models |
||||||
|
|
||||||
|
# Create your models here. |
||||||
|
class Subscriber(models.Model): |
||||||
|
email = models.EmailField() |
||||||
|
name = models.CharField(max_length=128) |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = 'MySubsciber' |
||||||
|
verbose_name_plural = 'List of Subscribers' |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
try: |
||||||
|
return self.name |
||||||
|
except: |
||||||
|
return '{0!s}'.format(self.id) |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
from django.test import TestCase |
||||||
|
|
||||||
|
# Create your tests here. |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
from django.conf.urls import url |
||||||
|
from . import views |
||||||
|
|
||||||
|
urlpatterns = [ |
||||||
|
url(r'^', views.landing, name='landing'), |
||||||
|
#url(r'^$', views.home, name='home'), |
||||||
|
] |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
from django.shortcuts import render |
||||||
|
from .forms import SubscriberForm |
||||||
|
from django.contrib import auth |
||||||
|
from products.models import * |
||||||
|
|
||||||
|
def landing(request): |
||||||
|
form = SubscriberForm(request.POST or None) |
||||||
|
|
||||||
|
if request.method == "POST" and form.is_valid(): |
||||||
|
print(form.cleaned_data) |
||||||
|
form.save() |
||||||
|
|
||||||
|
return render(request, 'landing/landing.html', locals()) |
||||||
|
|
||||||
|
|
||||||
|
def home(request): |
||||||
|
product_images = ProductImage.objects.filter(is_active=True, is_main=True, product__is_active=True) |
||||||
|
product_images_phones = product_images.filter(product__category__id=1) |
||||||
|
product_images_watches = product_images.filter(product__category__id=2) |
||||||
|
username = auth.get_user(request).username |
||||||
|
return render(request, 'landing/home.html', locals()) |
||||||
Loading…
Reference in new issue