Code Monkey home page Code Monkey logo

erehwon's People

Contributors

arunkumarp93 avatar gerygeo avatar karsco avatar lili2311 avatar lucysabin avatar marizoldi avatar neraks avatar shraddhag2 avatar yanabar avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

erehwon's Issues

Add functionality to switch between personal view and public view of map for logged in users

When the slider says 'Map' untitled4

the user is in one of their User pages: either the main page with the categories or in a specific category, or they are creating a project/idea/call for action . e.g.:
22a123

By moving the slider towards the 'Map', they switch to map view which is this:
10a123

If the user is in the view above, moving the slider:
untitled5

takes them back to the user space in the html page where they were before they switched to map.

Fix Database for Heroku

  • Split up Django settings into dev and prod
  • In production file we must use database url so that heroku and django can use the database In production settings file:
import dj_database_url
DATABASES['default']=  dj_database_url.config()
  • dj-database-url must be installed locally and added to requirements.txt

Design the visualisation search functions

(1) Identify the type of data users will be searching, set the filters.

(2) We will need to prioritise data based on commonly/often/sometimes/rarely searched to provide triggers for the search.

(3) Define how the search output will be visually represented in the visualisation.

Connect Django with D3

Once a Project or Idea is added from the form it appears automatically on the visualisation at its appropriate place

Reorder menu items vertically

Wireframe change: The Menu items that are laid out horizontally should be placed vertically to allow for more space to view the content.

Messages/Notification related tickets to create:

Tickets to create for Messages/Notification related functionality:

I. Add messages functionality to Erehwon.

1) Add packages and configuration to project

Overview:

Start with a new git clone from github.com/marizoldi/Erehwon, and install the django-postman and django-notifications-hq module:

Steps:

a) install/add to requirements.txt the django-postman and django-notifications-hq module, as well as dependencies such as django-ajax-selects.
b) add the new modules to the erehwon/settings/__init__.py file.
c) add POSTMAN relevant configuration to the erehwon/settings/__init__.py file, including SITE_ID. Minimum suggested:

SITE_ID = 1
POSTMAN_AUTO_MODERATE_AS = True  # default is None
# POSTMAN_SHOW_USER_AS = 'username'  # default is None
POSTMAN_NAME_USER_AS = 'username'  # default is None
POSTMAN_NOTIFIER_APP = "communicationApp"  # default is 'notification'

d) an example settings file can be seen at the leungant Erehwon fork on the fix-messages branch. (to check that branch out use git clone http://github.com/leungant/Erehwon -b fix-messages )
e) start a new 'communication' app manage.py startapp communicationApp
f) add the communicationApp to the settings file

2) Change Django Postman to use username instead of email address when sending messages.

a) alter settings/__init__.py
and set up POSTMAN_NAME_USER_AS = 'username' (and maybe POSTMAN_SHOW_USER_AS)
(refer to https://bitbucket.org/psam/django-postman/wiki/Quick_Start_Guide for more details)
b) add get_username class method to profiles models.py ErehwonUser to return (self.)username

3) (Optional/skip) At this point, one can use the default postman urls/views/templates to check the functionality if you have not done so in the past. Examples available in leungant/Erehwon -b fix-messages, under erehwon/urls.py, notificationApp/views.py and erehwon/templates

II. Implement URL for sending messages.

1) Create views.py and urls.py entries to send a message

Overview:

Create a function in communicationApp/views.py that is called from the erehwon/urls.py file that programmatically send messages. Thereafter, by calling the relevant URL one can send messages programmatically. Use this in the angular interface.

Steps:

to erehwon urls.py add something like:

 url(r'^api/sendmessage', api_send_message, name='Api Send Message View'),

to views.py add the following:

def api_create_message(request):
 #see documentation for postman api call: https://django-postman.readthedocs.io/en/latest/api.html#pm-write
 from postman.api import pm_write
 # Now we have to work out who to send from and who to send to for the pm_write call, which actually sends the message.
 # We are likely to get this from supplied URL parameters or the URL itself. Django populates request with parameters from the URL call. A succinct summary can be found here: http://django.cowhite.com/blog/working-with-url-get-post-parameters-in-django/ I imagine using POST parameters might be the most appropriate to start with: access the supplied parameters with e.g. request.POST['recipient']  or request.GET['message'] if you want to check things are working from end to end.

# With the recipient and sender usernames, get a User object with the following syntax.

 User = get_user_model() # needs from django.contrib.auth import get_user_model. This will return a Erehwon.Profile User.
sender_user=User.objects.get(username=sender)
recipient_user=User.objects.get(username=recipient)

print pm_write(sender=sender_user, recipient=recipient_user, subject='', body=message_to_send)

Test this by making calls through the browser with the relevant GET/POST parameters (either use GET urls or set up an HTML

testing page. When you make an AJAX call this should end up being more straightforward; see http://www.w3schools.com/xml/ajax_xmlhttprequest_send.asp for some example Javascript code to perform this.)

III. Set up messages view for ajax/angular style interface

Overview:

Create a function in communicationApp/views.py that is called from the erehwon/urls.py file to provide a list of all message between a user and a corresponder.
Set up a function in communicationApp/views.py that returns a HttpResponse containing the JSON required to display messages.
limit to last e.g. 80 messages, with pagination possible for history views.
something like...

from django.contrib.auth.decorators import login_required
@login_required
def api_get_conversation(request):
    """
    get messages
    """
    recipient = request.user
    sender = request.from
    ''' get a specific user e.g. sender with: '''
    from django.contrib.auth import get_user_model
    User = get_user_model()
    recipient_user = User.objects.get(username=recipient)
    sender_user = User.objects.get(username=sender)

    json_output = Message.objects.all().filter(etc ).toJSON etc

    from django.db.models.query_utils import Q
    json_output = Message.objects.filter(( Q(recipient=a1) & Q(sender=b1)) | (Q(recipient=b1) & Q(sender=a1))).toJSON etc
    return HttpResponse(output)

    recipient_id sender_id or recipient sender pair.

add a /api/conversation url to urls.py similar to the send_message url and test.

''' [Appendix]
Example query for OR query using Q objects.

Poll.objects.get(
    Q(question__startswith='Who'),
    Q(pub_date=date(2005, 5, 2)) | Q(pub_date=date(2005, 5, 6))
)

so for messages would be something like:

from django.db.models.query_utils import Q
conversation_messages = Message.objects.get(( Q(recipient=a1) & Q(sender=b1)) | (Q(recipient=b1) & Q(sender=a1))
Encode to JSON and return.

'''

IV. Get list of conversations

1) def api_list_conversations(request):

enables the conversation list view, which is a list of most recent conversations and the last message from each conversation.
e.g. return conversation.objects.get(recipient=request.user)
urls.py api/conversations or similar. Could use a regexp match on the URL in this instance, or stick to POST parameters. specify @login_required for security.

2) create a conversations model in communicationApp/models.py

recipient, sender, last_message_id, last_message_datetime, conversation_unread:boolean
makemigrations, migrate

3) add a hook (an additional method call) to api_send_message (and any other places where messages are created) that keeps the conversations model up to date. create a method that calls pm_write and then updates this user model.

def send_message(some, arguments):
    pm_write()
    update_conversations()
  • where update_conversations looks like:
def update_conversations(recipient, sender, message, datetime)
    conversation = Conversation.objects.get(recipient=recipient, sender=sender) # check exact query  syntax please
    if conversation is None:
        #make one
        conversation = Converation(recipient=recipient, sender=sender)
    # update current
    conversation[last_message] = message
    conversation[last_message_datetime] = datetime
    conversation[conversation_unread] = True
    conversation.save()

4) fetch conversations for user:

create view in views.py and url in urls.py to fetch list of conversations

   current_user = request.user
   conversations = Conversation.objects.get(recipient=current_user)

return conversations, preferably encoding it into JSON first so that Angular side will be able to deal with it.

5) add mark_conversation_read call to api_get_conversation to set the unread property on the Conversation to read, when the conversation is viewed.

   def mark_conversation_read(recipient, user):
       fetch conversation object
       set conversation[unread] = false
       conversation.save()

6) (if required) set up a tornado/golang sse/eventsource/websockets server to send message updates.

longpoll style: make request with last_updated time, server sends messages since or ignores and client side times out.
sse style: publish messages to subscribed parties. sending messages still happens via an ajax call.

V. Miscellaneous

1) fix inbox/notifications to show notification count for user

set up an api view to display the unread count if necessary.
Use this in a template, and use a TemplateRenderer object in urls.py to return a page.

{% load postman_tags %}
{% postman_unread as unread_count %}

{% if unread_count %}
    You have <strong>{{ unread_count }}</strong> unread messages.
{% endif %}

and in urls.py:
url(r'^api/notifications', TemplateView.as_view(template_name='notifications.html')),
where notifications.html is the name of the template in the templates directory that you put the above code in.

2) General site-related updates. Two choices:

For general site notifications/events into a different channel with a user called UPDATES,
or simply create new Updates model.
Would probably opt for number 2.
again, create views.py and urls.py entry.

Create initial header/navigation HTML and CSS (no dropdowns or interactions)

Do not worry about any interactions at the moment at all, just a static bar with the links and the navigation circles. No need to style or create any drop-downs yet or the toggle functionality.

screen shot 2017-03-14 at 11 04 23

Create News drop down (no interactions at this stage)

The News pop up windows will display in priority:
(1) Notifications of a new Project added to the visualisation (disregard the rest items on the drop down as shown in the picture below. These are for future versions)
(2) Any new Projects/Ideas/Calls for action that have been Added to the map in the last 24 hours (maybe capped in 10 - the rest can be found through search)

screen shot 2017-03-14 at 10 50 34

Create the "Add Idea" form

Create the form and model for ideas and add the 'add to database' functionality upon pressing button 'Add Idea'. No front-end at the moment - just use the default Django form button.

The form needs to have the following fields:
Title, Synopsis, Tags (multiple entries), Contributors (multiple entries), Attach to project which will show a list of the user's projects

Start by creating the single entry fields first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.