marizoldi / erehwon Goto Github PK
View Code? Open in Web Editor NEWPlatform for visualising sociopolitical interventions in Europe and beyond and for connecting people involved in them
Home Page: http://erehwon.herokuapp.com/
Platform for visualising sociopolitical interventions in Europe and beyond and for connecting people involved in them
Home Page: http://erehwon.herokuapp.com/
Amend the existing footer-wrap element in the dashboard layout to reflect the structure in the wireframes above: https://github.com/marizoldi/Erehwon/blob/master/erehwon/erehwon/templates/dashboard-layout.html
Amend the .footer
class: https://github.com/marizoldi/Erehwon/blob/master/frontend/styles/partials/_footer.scss
Any icons are in .svg format in https://github.com/marizoldi/Erehwon/tree/master/frontend/img
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.:
By moving the slider towards the 'Map', they switch to map view which is this:
If the user is in the view above, moving the slider:
takes them back to the user space in the html page where they were before they switched to map.
import dj_database_url
DATABASES['default']= dj_database_url.config()
requirements.txt
(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.
update https://github.com/marizoldi/Erehwon/blob/master/frontend/scripts/scripts.js or perhaps find a css trick (for the stickytop class) that allows a smooth page scroll
In the future we will also drop passwords for e-mail authentication per device. See how medium.com operates..
Update the current form and model for projects and add the 'add to database' functionality upon pressing button 'Add project'. No front-end at the moment - just use the default Django form button.
Once a Project or Idea is added from the form it appears automatically on the visualisation at its appropriate place
To be combined with Ajax and JQuery on the front-end. See also: https://blog.bixly.com/django-search-function-using-jquery-ajax
once this is complete #59
update https://github.com/marizoldi/Erehwon/blob/master/erehwon/erehwon/templates/layout.html
update https://github.com/marizoldi/Erehwon/blob/master/erehwon/erehwon/templates/layout.html to include the search form
should match the wireframes:
https://projects.invisionapp.com/share/S38QV1RCE#/screens/197658602
and when typing in:
https://projects.invisionapp.com/share/S38QV1RCE#/screens/205567381
Wireframe change: The Menu items that are laid out horizontally should be placed vertically to allow for more space to view the content.
Start with a new git clone from github.com/marizoldi/Erehwon, and install the django-postman and django-notifications-hq module:
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
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
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.
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.)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.
'''
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.
recipient, sender, last_message_id, last_message_datetime, conversation_unread:boolean
makemigrations, migrate
def send_message(some, arguments):
pm_write()
update_conversations()
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()
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.
def mark_conversation_read(recipient, user):
fetch conversation object
set conversation[unread] = false
conversation.save()
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.
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.
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.
Use S3DIRECT. Add default image too.
The current sign up email has example data and wrong url when using on the local it takes you to example.com
Currently Save form does not work. Also for editing form.
.header
class accordingly and any others used by the header to look like the wireframes. This is the header scss file: https://github.com/marizoldi/Erehwon/blob/master/frontend/styles/partials/_header.scssDo 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.
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)
Download Alternates Thin from
https://www.fontsquirrel.com/fonts/montserrat and use it in the project
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.