Validation in Railway.js on module object - railway.js

am new to Railway.js (one of those cases where someone else wrote this peace of software that I now need to update - great grr!)
I got a "Notification" model and want to add validation that if user don't provide a field from the UI I display a error like: "Message Required"
How do I do this?
Thank you!

refer to jugglingdb documentation. you need validator:
Notification.validatesPresenceOf('message')

Related

How to get Django Report Builder working properly?

Documentation provided by Burke isn't very thorough and there isn't a lot of information on Django Report Builder yet, not even youtube videos. Does anybody have any information on how to get work Report Builder Working in Django? I currently keep getting this error message:
(1146, "Table 'epic_test2.report_builder_report' doesn't exist")
I've installed it, but I can't create reports yet and the documentation I do have isn't very helpful. Any advice would be great! Thanks!
UPDATE TO POST/ 5.12.15 -
I fixed the first issue, but now I have a new error. :) Yay. It's a Field Error
"Cannot Resolve keyword 'name' into field. Choices are: app_label, id, logentry, model, permission, report.
ANY clues for this one would be helpful... going into third hour of troubleshooting. :)
Thanks!
~Heather
Sounds like you may need to run a migrate to create the Report Builder tables required.
python manage.py migrate
I would suggest you do a full search in your code for "name", something like: grep -R "name" ., and see where it's defined, is it a valid field in models.py, etc.
I've had similar error before, turned out, I updated my variable name from something like "name" to "new_name" in my model. The way report-builder works, it saves column (field) name in the database. If it's an old field name, there will be error. Luckily this is easy to fix: go to report-builder UI, remove the row for that column, then add the column back, then the new field name would be saved.
Hope this helps.

One page checkout without login/registration

How do I make the buying process very simple without registration:
What I need is here?
catalog/controller/checkout
catalog/language/english/checkout
catalog/model/checkout
catalog/view/theme/default/template/checkout
Or somewhere else?
I have simplified the registration form:
http://i62.tinypic.com/veufqp.jpg
A problem with catalog\model\account\customer.php
http://i59.tinypic.com/11ujfq0.jpg
I understand what went wrong, the model does not receive the necessary variables.
But how to drown out the missing variables?
The right to request in the model or you can somehow do it in the controller?
Location data model takes ?:
- POST
- date
- session

Changing POST data prior to saving a model in Django REST Framework

Disclaimer: I'm a DRF/class-based-views newb.
I have a situation where the client to my API can't know the ID of a resource, but it does know a unique identifier of that resource (its name).
This is a problem when the client sends a separate resource that has a Foreign Key to the first via POST. For example... the client sends the following data (Signal being the FK):
{"signal_name": "signal1", "value": 5}
But the Model expects:
{"signal": 1, "value": 5}
When self.CONTENT gets to my custom post method, it's already been validated and is empty. So, where/how can I swap that data out prior to the data getting validated/rejected?Do I need a custom validation method?
Thanks for any suggestions!
I tried messing with the fields and extra-fields attributes on the resource, but couldn't get it to not validate it as wrong. So I ended up just adding the field in the 'signal_name' field into the model and matching it up to the signal's id in the post method. (Thankfully, in this case we had a non-enforced FK to Signal, so I could do wait to give a value to signal) I'll check back for a few days to see if anyone actually knows how to do this better. Also, thanks for the suggestions Pizza and Tom!

Real example of Ember.js

Please give me real example of emberjs. This example will help me understand how to write in emberjs.
Description of example:
Please open this link first:
http://jsfiddle.net/kwladyka/KhQvu/2/
(this is prototype to better understand what i am talking about)
And then read:
Emberjs download Groups.owner by JSON from json.php?name=groups-owner&user_id=58 and Groups.member from json.php?name=groups-member&user_id=58. Both in Groups.all.
In object Groups i have all values of arrays what i read from JSON. I want example read something like that: owner[2][name].
Then from CreateGroupsSelect i want read Groups.all and create ListBox with values group_id and names name. And when i change select i want change <p>You select {{name}} with id {{id}}</p> and refresh data in other View emberjs objects.
I will be really gratefull for help. I am trying learn emberjs but i totally block with this example.
Ok, so i have many questions :)
1)
How to bind value form input select to attribute in controller
var val = $('select option:selected').val();
Where can i find list of possible ussage like a "select option:selected". Any documentatin for that? Where?
2)
"didInsertElement"
How can i know i should use this? How should i looking in documentation to know that? Why not Ember.Select.Change for that?
3)
Why author use "View", i thought for select i should use class "select"?
4)
Seriously this is my first language when i fill all is so random and i dont have any idea how to know what i can write and where. I fill really stupid with that. Any hint how to understand that?
5)
Ok so step by step...
First of all i want read JSON and prepare data to use.
Organizer.Groups = Ember.Object.extend({
owner: [],
member: [],
all: function(){
var owner = this.get('owner');
var member = this.get('member');
return owner.concat(member);
}.property('owner', 'member'),
});
a) "Object" is good choice for that?
b) I want fill "owner" by array from "json.php?name=groups-owner&user_id=58". How to do that? Did i define "owner" corretly or i should write "ArrayController" or something else for that? Mayby just "Array" or "ArrayProxy"? I am filling so confuse now.
c) How should i initiate load data from JSON? I want do this only one time on the beginning.
PS Sorry if you fill my questions are so stupid but i really dont know answers and i dont hide this :)
Here is an example of how to work with select menu in Ember js
select dropdown with ember
Here is an example of working with routes and outlet helper
Right way to do navigation with Ember
If you use routing make sure you have ember latest, routing is still not released.
Router / StateManager - can't make it work
When using latest emberjs refer to documentation in source code, the documentation in ember site will be for present stable release.
https://github.com/emberjs/ember.js
The links to routing is provided from your fidle title "Router with dynamic routes"
It will be hard to solve your complete problem, give it a try starting with the routing example from above, when you are stuck ask more specific questions, we'll be happy to help.
EDIT : Some of the links are already outdated.

Is there a signal or anything similar to a "pre_select" in django?

I'm creating a system in django and it'd be really helpful to have a signal that is called every time a SQL "select" query is done on the database. In other words, does anyone know if there is something like a "pre_select" or "post_select" signal method?
I found the signal "connection_created" in the django docs, but couldn't find any clues of how to use it and less about accessing the model that called it. The official documentation just say that it exists but don't give a simple using example... =/
EDIT:
The connection_created just works when the connection is created (how its name says), so, I still without a solution =/.
An example of what I want would be the execution of this queries on distinct objects:
ExampleObject1.objects.filter(attribute=somevalue)
ExampleObject2.objects.filter(attribute=somevalue)
ExampleObject3.objects.filter(attribute=somevalue)
So a function is called receiving the data from each them just before each query being sent to the database in order to threat data, log, etc.
I imagine that exists some functionality like that in django because django log system appears to use something alike.
Any help is welcome. Thanks in advance!
From http://dabapps.com/blog/logging-sql-queries-django-13/
It's not in the form of signal, but it allows you to track all queries. Tracking specific selects should be doable by providing customized log handlers.
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
#make your queries now...