gearsystems / publicportal

Public portal software which takes uploads of photographs and locations and stores them on the server.
0 stars 12 forks source link

Merging hackathon development #18

Closed makalaaneesh closed 9 years ago

makalaaneesh commented 9 years ago

Added bot service which does long polling using the loklak search API which looks for live data from a particular user/bot ID and uses a conversation based approach to help users register complaints via twitter instead of using the app. Currently uses the nlp library for text analysis but needs more work, the basic foundation now is stable and can be worked on.

sudheesh001 commented 9 years ago

Review 1 made, Pushing review to @kranthikiran01 to test and do the merge.

kranthikiran01 commented 9 years ago

@sudheesh001 Shall review and merge!

@makalaaneesh great job!

acemaster commented 9 years ago

@sudheesh001 and @kranthikiran01 we are planning to add two more features by this weekend

  1. Image upload for chatbot
  2. Getting type of complaint from the tweet or message itself
sudheesh001 commented 9 years ago

@makalaaneesh @acemaster Can you update the requirements.txt with the new env requirement requirements by doing pip freeze > requirements.txt that should get this patch good for a merge.

acemaster commented 9 years ago

@sudheesh001

  1. Added base64 image upload for GEARBOT
  2. Requirements.txt updated
sudheesh001 commented 9 years ago

Update the following patch to the existing pull request to remove the Keyerror during migrations. Also update the .gitignore file

diff --git a/foundation/migrations/0001_initial.py b/foundation/migrations/0001_initial.py
deleted file mode 100644
index ae42871..0000000
--- a/foundation/migrations/0001_initial.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
-from django.conf import settings
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
-    ]
-
-    operations = [
-        migrations.CreateModel(
-            name='Complaint',
-            fields=[
-                ('id', models.AutoField(serialize=False, primary_key=True)),
-                ('title', models.CharField(max_length=100)),
-                ('type', models.CharField(max_length=10)),
-                ('description', models.TextField()),
-                ('difficulty', models.IntegerField(default=0)),
-                ('userid', models.IntegerField(null=True)),
-                ('location', models.CharField(max_length=100)),
-                ('latitude', models.CharField(max_length=30)),
-                ('longitude', models.CharField(max_length=30)),
-                ('approved', models.BooleanField(default=True)),
-                ('image', models.ImageField(upload_to=b'complaint_images', blank=True)),
-            ],
-            options={
-            },
-            bases=(models.Model,),
-        ),
-        migrations.CreateModel(
-            name='IncompleteComplaint',
-            fields=[
-                ('id', models.AutoField(serialize=False, primary_key=True)),
-                ('title', models.CharField(max_length=100, null=True)),
-                ('type', models.CharField(max_length=10, null=True)),
-                ('description', models.TextField(null=True)),
-                ('userid', models.IntegerField(null=True)),
-                ('location', models.CharField(max_length=100, null=True)),
-                ('latitude', models.CharField(max_length=30, null=True)),
-                ('longitude', models.CharField(max_length=30, null=True)),
-                ('image', models.ImageField(upload_to=b'incomplete-complaints', blank=True)),
-            ],
-            options={
-            },
-            bases=(models.Model,),
-        ),
-        migrations.CreateModel(
-            name='Mapobject',
-            fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('location', models.CharField(max_length=100)),
-                ('latitude', models.CharField(max_length=30)),
-                ('longitude', models.CharField(max_length=30)),
-                ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
-            ],
-            options={
-            },
-            bases=(models.Model,),
-        ),
-        migrations.CreateModel(
-            name='Tweet',
-            fields=[
-                ('parent_tweet_id', models.AutoField(serialize=False, primary_key=True)),
-                ('mode', models.IntegerField(default=0, null=True)),
-                ('reply_to_tweetid', models.CharField(max_length=100, null=True)),
-                ('state', models.IntegerField(default=-1)),
-                ('statelist', models.CharField(default=b'0000000', max_length=100)),
-                ('referral_id', models.ForeignKey(to='foundation.IncompleteComplaint')),
-            ],
-            options={
-            },
-            bases=(models.Model,),
-        ),
-    ]
diff --git a/foundation/migrations/0002_auto_20150129_2141.py b/foundation/migrations/0002_auto_20150129_2141.py
deleted file mode 100755
index ea5c0bc..0000000
--- a/foundation/migrations/0002_auto_20150129_2141.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('foundation', '0001_initial'),
-    ]
-
-    operations = [
-        migrations.AlterField(
-            model_name='complain',
-            name='difficulty',
-            field=models.IntegerField(default=0),
-            preserve_default=True,
-        ),
-    ]
diff --git a/foundation/migrations/0003_auto_20150129_2149.py b/foundation/migrations/0003_auto_20150129_2149.py
deleted file mode 100755
index 1620fd5..0000000
--- a/foundation/migrations/0003_auto_20150129_2149.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('foundation', '0002_auto_20150129_2141'),
-    ]
-
-    operations = [
-        migrations.AlterField(
-            model_name='complain',
-            name='userid',
-            field=models.IntegerField(null=True),
-            preserve_default=True,
-        ),
-    ]
diff --git a/foundation/migrations/__init__.py b/foundation/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/static/js/chat.js b/static/js/chat.js
index 875e0be..471ce89 100644
--- a/static/js/chat.js
+++ b/static/js/chat.js
@@ -25,7 +25,7 @@ function($scope,$http,$cookies,$sce){
          var newchat={'message':$scope.newchat,'uid':1};
            $scope.chats.push(newchat);
            var in_data = jQuery.param({'content': $scope.newchat,'csrfmiddlewaretoken': $cookies.csrftoken, 'state_flag': $scope.state, 'mode': $scope.mode,'complaint_id':$scope.complaint_id, 'state_list': $scope.statelist});
-           var url='http://127.0.0.1:8000/livechatbot';
+           var url='http://localhost:8000/livechatbot';
            var my_data={test: 'data'};
            $http.post(url, in_data)
           .success(function(out_data) {
@@ -64,7 +64,7 @@ function($scope,$http,$cookies,$sce){
    $scope.getloc=function(){

       var in_data = jQuery.param({'csrfmiddlewaretoken': $cookies.csrftoken,'complaint_id':$scope.complaint_id});
-      var url='http://127.0.0.1:8000/getlocation';
+      var url='http://localhost:8000/getlocation';
       var my_data={test: 'data'};
       $http.post(url, in_data)
           .success(function(out_data) {
@@ -76,7 +76,7 @@ function($scope,$http,$cookies,$sce){
             iframe.style.display = "block";
             iframe.style.width="100%";
             iframe.style.height="100%";
-            iframe.src = "http://127.0.0.1:8000/mapareachatbot/"+$scope.location_temp+"/";
+            iframe.src = "http://localhost:8000/mapareachatbot/"+$scope.location_temp+"/";
             document.getElementById('modal_map').appendChild(iframe);
             $('#myModal').modal('show');
           }
@@ -101,7 +101,7 @@ function($scope,$http,$cookies,$sce){
       $scope.complaint_imagetag=$sce.trustAsHtml(image_tag);
       $scope.chats.push(newchat);
       var in_data = jQuery.param({'content': $scope.complaint_image.base64,'csrfmiddlewaretoken': $cookies.csrftoken, 'state_flag': $scope.state, 'mode': $scope.mode,'complaint_id':$scope.complaint_id, 'state_list': $scope.statelist});
-      var url='http://127.0.0.1:8000/chatbotaddpicture';
+      var url='http://localhost:8000/chatbotaddpicture';
       var my_data={test: 'data'};
       $http.post(url, in_data)
           .success(function(out_data) {
makalaaneesh commented 9 years ago

@sudheesh001 Made the changes. Run populate.py to populate the db with a few test complaints near JRC conventions and trade fairs..

sudheesh001 commented 9 years ago

@karajrish In the chat bot UI I am unable to see the messages once the user posts them.

screen shot 2015-08-30 at 8 46 34 am

Please fix that and we are good to merge.

makalaaneesh commented 9 years ago

We fixed that yesterday. @vivekace push the changes.

sudheesh001 commented 9 years ago

Please open a new PR for that, we're temporarily merging this.