Skip to content

Commit

Permalink
[Fix] fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
penny-wanjiru committed Aug 2, 2016
2 parents 0bec4a8 + 86a1f05 commit f0010c8
Show file tree
Hide file tree
Showing 17 changed files with 1,039 additions and 361 deletions.
169 changes: 90 additions & 79 deletions troupon/accounts/templates/account/register_merchant.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
{% extends "account/profile_base.html" %}
{% load static%}

{% block extended_css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
{% endblock extended_css %}

{% block sidebar_menu %}
{% with active_tab='Merchant' %}
{{ block.super }}
{% endwith %}
{% endblock sidebar_menu %}

{% extends "account/profile_base.html" %} {% load static%} {% block extended_css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
{% endblock extended_css %}
{% block sidebar_menu %}
{% with active_tab='Merchant' %}
{{ block.super }}
{% endwith %}
{% endblock sidebar_menu %}
{% block subview %}
<div class="row">
<div class="col-sm-7">

<form method="POST" id="merchantform" action="{% url 'account_merchant_register' %}">
<form method="POST" id="merchantform" action="{% url 'account_merchant_register' %}" enctype="multipart/form-data">
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
<div class="row">
<div class="col-sm-7">

<div class="form-group col-lg-12">
<label>Name</label>
Expand All @@ -25,81 +19,98 @@
</div>
</div>

<div class="custom-form-group col-lg-12">
<label>Address:</label>
<div class="custom-input-group">
<input type="text" name="address" class="form-control" id="" value="" placeholder="company address">
<div class="custom-form-group col-lg-12">
<label>Address:</label>
<div class="custom-input-group">
<input type="text" name="address" class="form-control" id="" value="" placeholder="company address">
</div>
</div>
</div>

<div class="custom-form-group col-lg-12">
<label>Country<span class="label-asterik">*</span></label>
<div class="custom-input-group">
<span class="right-icon"><i class="fa fa-angle-down"></i></span>
<select name="user_country" placeholder="Kenya" id="user-country">
<option value="0" selected>Select your country</option>
{% for choice in countries.choices %}
<option value="{{ choice.0 }}">
{{ choice.1 }}
</option>
{% endfor %}
</select>
<div class="custom-form-group col-lg-12">
<label>Country<span class="label-asterik">*</span></label>
<div class="custom-input-group">
<span class="right-icon"><i class="fa fa-angle-down"></i></span>
<select name="user_country" placeholder="Kenya" id="user-country">
<option value="0" selected>Select your country</option>
{% for choice in countries.choices %}
<option value="{{ choice.0 }}">
{{ choice.1 }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>

<div class="custom-form-group col-lg-12 hidden" id="kenyan-locations">
<label>Location<span class="label-asterik">*</span></label>
<div class="custom-input-group">
<span class="right-icon"><i class="fa fa-angle-down"></i></span>
<select name="kenya_user_location" placeholder="Nairobi">
<option value="0" selected>Select your location</option>
{% for choice in locations_kenya.choices %}
<option value="{{ choice.0 }}" {% if choice.0 == locations_kenya.default %}selected{% endif %}>
{{ choice.1 }}
</option>
{% endfor %}
</select>
<div class="custom-form-group col-lg-12 hidden" id="kenyan-locations">
<label>Location<span class="label-asterik">*</span></label>
<div class="custom-input-group">
<span class="right-icon"><i class="fa fa-angle-down"></i></span>
<select name="kenya_user_location" placeholder="Nairobi">
<option value="0" selected>Select your location</option>
{% for choice in locations_kenya.choices %}
<option value="{{ choice.0 }}" {% if choice.0 == locations_kenya.default %}selected{% endif %}>
{{ choice.1 }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>

<div class="custom-form-group col-lg-12 hidden" id="nigerian-locations">
<label>Location<span class="label-asterik">*</span></label>
<div class="custom-input-group">
<span class="right-icon"><i class="fa fa-angle-down"></i></span>
<select name="nigeria_user_location" placeholder="Lagos">
<option value="0" selected>Select your location</option>
{% for choice in locations_nigeria.choices %}
<option value="{{ choice.0 }}" {% if choice.0 == locations_nigeria.default %}selected{% endif %} >
{{ choice.1 }}
</option>
{% endfor %}
</select>
<div class="custom-form-group col-lg-12 hidden" id="nigerian-locations">
<label>Location<span class="label-asterik">*</span></label>
<div class="custom-input-group">
<span class="right-icon"><i class="fa fa-angle-down"></i></span>
<select name="nigeria_user_location" placeholder="Lagos">
<option value="0" selected>Select your location</option>
{% for choice in locations_nigeria.choices %}
<option value="{{ choice.0 }}" {% if choice.0 == locations_nigeria.default %}selected{% endif %} >
{{ choice.1 }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>

<div class="custom-form-group col-lg-12">
<label>Email:</label>
<div class="custom-input-group">
<input type="email" name="email" class="form-control" id="" value="" placeholder="name@businessemail.com">
</div>
</div>
<div class="custom-form-group col-lg-12">
<label>Email:</label>
<div class="custom-input-group">
<input type="email" name="email" class="form-control" id="" value="" placeholder="name@businessemail.com">
</div>
</div>

<div class="custom-form-group col-lg-12">
<label>Phone Number <span class="label-asterik">*</span></label>
<div class="custom-input-group">
<input type="tel" name="telephone" id="mobile-number" value="" placeholder="">
<span id="valid-msg" class="hide">✓ Valid</span>
<span id="error-msg" class="hide">Invalid number</span>
<input id="hidden" type="hidden" name="intlnumber">
<div class="custom-form-group col-lg-12">
<label>Phone Number <span class="label-asterik">*</span></label>
<div class="custom-input-group">
<input type="tel" name="telephone" id="mobile-number" value="" placeholder="">
<span id="valid-msg" class="hide">✓ Valid</span>
<span id="error-msg" class="hide">Invalid number</span>
<input id="hidden" type="hidden" name="intlnumber">
</div>
</div>
</div>
<div class="col-sm-5 ">
<div class="custom-form-group col-sm-12">
<label style="margin-bottom: 20px;">Merchant Logo</label> {% csrf_token %}
<div class="images">
<img id="merchant-logo" src="{% static 'img/logo-v-lg.png' %}"/>
</div>
<label class="file-upload-label">
<input id="file-upload" name="logo" type="file" size="#" onchange="previewImage();">
<span class="glyphicon glyphicon-folder-open" aria-hidden="true" ></span>Select Logo
</label>

</div>
</div>
</div>

<div class="custom-form-group btn-lg col-lg-1">
<input id="save" type = "submit", value = "Submit" align="left" class="btn-action"/>
<div class="row">
<div class="custom-form-group btn-lg col-lg-12">
<input id="save" type="submit" , value="Submit" align="left" class="btn-action" />
</div>
</div>
</form>

</div>
</div>

{% endblock subview %}
{% block extended_js %}
<script src={% static 'js/merchant.js' %}></script>
{% endblock %}
7 changes: 5 additions & 2 deletions troupon/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def post(self, request, **kwargs):
context_instance=RequestContext(request)
)


class TransactionsView(TemplateView):
"""View transactions for a user"""

def get(self, request):
"""Renders a page with a table showing a deal,
quantity bought, time of purchase, and its price
Expand Down Expand Up @@ -186,12 +188,12 @@ def post(self, request, **kwargs):
address = request.POST.get('address')
slug = slugify(name)
userprofile = request.user.profile

logo = request.FILES.get('logo')
merchant = Merchant(
name=name, country=country, location=location,
telephone=telephone, email=email,
address=address, slug=slug,
intlnumber=intlnumber,
intlnumber=intlnumber, logo=logo,
userprofile=userprofile
)

Expand Down Expand Up @@ -269,6 +271,7 @@ def get(self, request, *args, **kwargs):

try:
if request.user.profile.merchant:

if(not Message.confirmation_sent(request.user)):
# send message to admin that a merchant has been enabled
body = """%s %s just verified his phone number.
Expand Down
1 change: 0 additions & 1 deletion troupon/cart/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def test_checkout_view(self):
self.driver.find_element_by_xpath(
xpath_checkout_button).click()


def tearDown(self):
self.driver.quit()
super(CheckoutViewTest, self).tearDown()
Expand Down
20 changes: 20 additions & 0 deletions troupon/deals/migrations/0002_advertiser_logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import cloudinary.models


class Migration(migrations.Migration):

dependencies = [
('deals', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='advertiser',
name='logo',
field=cloudinary.models.CloudinaryField(default=b'img/default_logo.png', max_length=255, blank=True),
),
]
18 changes: 18 additions & 0 deletions troupon/deals/migrations/0003_remove_advertiser_logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('deals', '0002_advertiser_logo'),
]

operations = [
migrations.RemoveField(
model_name='advertiser',
name='logo',
),
]
20 changes: 20 additions & 0 deletions troupon/deals/migrations/0004_advertiser_logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import cloudinary.models


class Migration(migrations.Migration):

dependencies = [
('deals', '0003_remove_advertiser_logo'),
]

operations = [
migrations.AddField(
model_name='advertiser',
name='logo',
field=cloudinary.models.CloudinaryField(default=b'img/default_logo.png', max_length=255, blank=True),
),
]
25 changes: 25 additions & 0 deletions troupon/deals/migrations/0005_auto_20160801_0951.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import cloudinary.models


class Migration(migrations.Migration):

dependencies = [
('deals', '0004_advertiser_logo'),
]

operations = [
migrations.AddField(
model_name='deal',
name='type',
field=models.SmallIntegerField(default=1, choices=[(1, b'Physical'), (2, b'Virtual')]),
),
migrations.AlterField(
model_name='advertiser',
name='logo',
field=cloudinary.models.CloudinaryField(default=b'img/logo-v-lg.png', max_length=255, blank=True),
),
]
19 changes: 16 additions & 3 deletions troupon/deals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
(-1, "Show All"),
]

# Category of deal as either physical or virtual
DEAL_TYPES = [(1, 'Physical'), (2, 'Virtual')]


class Deal(models.Model):
"""Deals within the troupon system are represented by this
Expand Down Expand Up @@ -101,6 +104,7 @@ class Deal(models.Model):
active = models.BooleanField(default=False)
featured = models.BooleanField(default=False)
max_quantity_available = models.IntegerField()
type = models.SmallIntegerField(choices=DEAL_TYPES, default=1)
date_created = models.DateField(auto_now_add=True)
date_last_modified = models.DateField(auto_now=True)
date_end = models.DateField(blank=True, null=True)
Expand Down Expand Up @@ -156,6 +160,7 @@ class ImageMixin(object):
"""Mixes in an image property which is a random image selected from
all available deals
"""

def image(self):
"""Retrieve random photo of deal under this category
"""
Expand All @@ -180,11 +185,19 @@ class Advertiser(ImageMixin, models.Model):
address = models.CharField(max_length=200, default='')
country = models.SmallIntegerField(choices=COUNTRY_CHOICES, default=2)
if country == 1:
location = models.SmallIntegerField(choices=NIGERIAN_LOCATIONS, default=25)
location = models.SmallIntegerField(
choices=NIGERIAN_LOCATIONS, default=25)
else:
location = models.SmallIntegerField(choices=KENYAN_LOCATIONS, default=47)
location = models.SmallIntegerField(
choices=KENYAN_LOCATIONS, default=47)
telephone = models.CharField(max_length=60, default='')
email = models.EmailField(default='')
logo = CloudinaryField(
resource_type='image',
type='upload',
blank=True,
default="img/logo-v-lg.png"
)

def __str__(self):
return "{0}".format(self.name)
Expand Down Expand Up @@ -222,7 +235,7 @@ def set_deal_slug(sender, instance, **kwargs):
slug = slugify('%s %s' % (instance.title, date_created))

deal_slug_exists = Deal.objects.filter(
slug__startswith=slug).order_by('-date_created')
slug__startswith=slug).order_by('-date_created')

if deal_slug_exists:
deal_title_slug = slugify(instance.title)
Expand Down
Loading

0 comments on commit f0010c8

Please sign in to comment.