Commits

Anonymous committed 9edc1b4

fix some bugs

  • Participants
  • Parent commits 60f445a

Comments (0)

Files changed (11)

     def GET(self):
         f = storeForm()
         d['f'] = f
+        d['malls'] = getMalls()
         return render.store_create(**d)
 
     @login_required
             return web.seeother('/store/view/%s' % storeId)
         else:
             d['f'] = f
+            d['malls'] = getMalls()
             return render.store_create(**d)
 
 class store_view(object):
             sql = sql + 'm.cityId = %s ' % i.city
         elif i.city and (i.keyword or i.state):
             sql = sql + 'AND m.cityId = %s ' % i.city
-        if i.latitude and i.longitude and i.distance and not i.keyword and not i.state and not i.city:
-            sql = sql + '(POW((%s - m.latitude), 2) + POW((%s - m.longitude), 2)) <= POW(%s, 2) ' % (i.latitude, i.longitude, i.distance)
-        elif i.latitude and i.longtitude and i.distance and (i.keyword or i.state or i.city):
-            sql = sql + 'AND (POW((%s - m.latitude), 2) + POW((%s - m.longitude), 2)) <= POW(%s, 2) ' % (i.latitude, i.longitude, i.distance)
+        if i.latitude and i.longitude and i.distance and (not i.keyword) and (not i.state) and (not i.city):
+            sql = sql + 'ACOS((COS(%s)*COS(m.latitude)*COS(%s)*COS(m.longitude) + COS(%s)*SIN(%s)*COS(m.latitude)*SIN(m.longitude)))*6378*1000 <= %s ' % (i.latitude, i.longitude, i.latitude, i.longitude, i.distance)
+        elif i.latitude and i.longitude and i.distance and (i.keyword or i.state or i.city):
+            sql = sql + 'AND ACOS((COS(%s)*COS(m.latitude)*COS(%s)*COS(m.longitude) + COS(%s)*SIN(%s)*COS(m.latitude)*SIN(m.longitude)))*6378*1000 <= %s ' % (i.latitude, i.longitude, i.latitude, i.longitude, i.distance)
         if not i.keyword and not i.state and not i.state and not i.city and not i.latitude and not i.longitude and not i.distance:
             return json.dumps([])
         sql = sql + 'GROUP BY m.id ORDER BY m.name ASC LIMIT %d, %d' % ((page-1)*pageSize, pageSize)
-        if i.keyword or i.state or i.city or i.latitude or i.longitude or i.distance:
+        if i.keyword or i.state or i.city or (i.latitude and i.longitude and i.distance):
             malls = list(db.query(sql))
-            if malls[0].mallId is None:
+            if len(malls) == 0:
                 malls = []
         else:
             malls = []

File templates/admin/coupon_create.html

 <script type="text/javascript" src="/static/js/jquery-ui-1.7.2.custom.min.js"></script>
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(3)').addClass('active');
+        $('.sideNav').find('a:eq(2)').addClass('active');
 
         mallID = $('#mall').attr('value');
         $.ajax({

File templates/admin/coupon_edit.html

 <script type="text/javascript" src="/static/js/jquery-ui-1.7.2.custom.min.js"></script>
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(3)').addClass('active');
+        $('.sideNav').find('a:eq(2)').addClass('active');
 
         /**
         mallID = $('#mall').attr('value');

File templates/admin/coupon_list.html

 {% include '_leftbar.html' %}
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(3)').addClass('active');
+        $('.sideNav').find('a:eq(2)').addClass('active');
 
         mallID = $('#mall').attr('value');
         $.ajax({

File templates/admin/coupon_view.html

 {% include '_leftbar.html' %}
 <script type="text/javascript">
     $(document).ready(function() {
-        $('.sideNav').find('a:eq(3)').addClass('active');
+        $('.sideNav').find('a:eq(2)').addClass('active');
     });
 </script>
 <h2><a href="/admin">DASHBOARD</a> &raquo; <a href="/admin/coupon/list" class="active">Coupon Manage</a></h2>

File templates/admin/store_create.html

 {% include '_leftbar.html' %}
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(2)').addClass('active');
+        $('.sideNav').find('a:eq(1)').addClass('active');
     });
 </script>
 <h2><a href="/admin">DASHBOARD</a> &raquo; <a href="/admin/store/list" class="active">Store Manage</a></h2>
         <table cellpadding="0" cellspacing="0">
             <tr>
                 <th id="mall">Mall(*)</th>
-                <td>{{ f.mallId.render() }}</td>
+				<td><select name="mallId">{% for v in malls %}<option value="{{ v[0] }}">{{ v[1] }}</option>{% endfor %}</select></td>
             </tr>
             <tr>
                 <th>Name(*)</th>

File templates/admin/store_edit.html

 {% include '_leftbar.html' %}
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(2)').addClass('active');
+        $('.sideNav').find('a:eq(1)').addClass('active');
     });
 </script>
 <h2><a href="/admin">DASHBOARD</a> &raquo; <a href="/admin/store/list" class="active">Store Manage</a></h2>

File templates/admin/store_list.html

 {% include '_leftbar.html' %}
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(2)').addClass('active');
+        $('.sideNav').find('a:eq(1)').addClass('active');
     });
 </script>
 <h2><a href="/admin">Dashboard</a> &raquo; <a href="/admin/store/list" class="active">Store Manage</a></h2>

File templates/admin/store_view.html

 {% include '_leftbar.html' %}
 <script type="text/javascript">
     $(document).ready(function(){
-        $('.sideNav').find('a:eq(2)').addClass('active');
+        $('.sideNav').find('a:eq(1)').addClass('active');
     });
 </script>
 <h2><a href="/admin">DASHBOARD</a> &raquo; <a href="/admin/store/list" class="active">Store Manage</a></h2>
                     f.content.value)
             subject = "You've got a new contact from %s." % f.email.value
             try:
-                web.sendmail('support@mallmagicapp.com',
+                web.sendmail('mallsalesapp@gmail.com',
                     f.email.value,
                     subject,
                     body, headers={'Content-Type':'text/html; charset=utf-8'})