This is my first post here, apologize if my English is not perfect....
I am going to give you a short example of want I am looking for, and I will appreciate your opinion about the best approach to solve the described scenario.
I am not an expert frontend developer, so I if something it is not clear, please not hesitate to ask it.
[Example of app OOTB]
We have application with frontend, backend and database totally working with the following data model:
-Clients { Name , Address }
-Products { Name , Price }
-Orders { ProductID , ClientID , Delivery Date}
So, at this point we have one app that allows users:
CRUD orders , clients and products
*CRUD = Create, read, update and delete
[Challenge]
How can I design the app to make it configurable?
When I say configurable means not coding the views and the model again, means having one code that could generate the views and model from a config file.
Let me give an example of configurable:
We have the app OOTB (out of the box) as explained previously, but now we have a different client and the app need changes:
-Clients { Name, List of Addresses , Phone , Bank account , etc...}
-Products { Name, CreationDate, Price , ExpirationDate , etc...}
How can I code the frontend with angularJS or any other framework to make the views and the model configurable?
It sounds like a relatively simple website with use authentication / login.
Try this tutorial and see how you get on:
Getting Started with Entity Framework 6 Code First using MVC 5
Related
I'm managing a company website, where we have to display our products. We however do not want to handle the admin edit for this CPT, nor offer the ability to access to the form. But we have to read some product data form the admin edit page. All has to be created or updated via our CRM platform automatically.
For this matter, I already setup a CPT (wprc_pr) and registered 6 custom hierarchical terms: 1 generic for the types (wprc_pr_type) and 5 targeting each types available: wprc_pr_rb, wprc_pr_sp, wprc_pr_pe, wprc_pr_ce and wprc_pr_pr. All those taxonomies are required for filtering purposes (was the old way of working, maybe not the best, opened to suggestions here). We happen to come out with archive pages links looking like site.tld/generic/specific-parent/specific-child/ which is what is desired here.
I have a internal tool, nodeJS based, to batch create products from our CRM. The job is simple: get all products not yet pushed to the website, format a new post, push it to the WP REST API, wait for response, updated CRM data in consequence, and proceed to next product. Handle about 1600 products today on trialn each gone fine
The issue for now is that in order for me to put the correct terms to the new post, I have to compute for each product the generic type and specific type children.
I handled that by creating 6 files, one for each taxonomy. Each file is basically a giant JS object with the id from the CRM as a key, and the term id as a value. My script handles the category assertion like that:
wp_taxonomy = [jsTaxonomyMapper[crm_id1][crm_id2]] // or [] if not found
I have to say it is working pretty well, and that I could stop here. But I will have to take that computing to the wp_after_insert_post hook, in order to reaffect the post to the desired category on updated if something changed on the CRM.
Not quite difficult, but if I happen to add category on the CRM, I'll have to manually edit my mappers to add the new terms, and believe me that's a hassle.
Not waiting for a full solution here, but a way to work the thing. Maybe a way to computed those mappers and store their values in the options table maybe, or have a mapper class, I don't know at all.
Additional information:
Data from the CRM comes as integers (ids corresponding to a label) and the mappers today consist of 6 arrays (nested or not), about 600 total entries.
If you have something for me, or even suggestions to simplify the process, I'll go with it.
Thanks.
EDIT :
Went with another approach, see comment below.
I made a simple Angular + Firebase app, which you can see here.
I want to add user authentication to it using Firebase, and have successfully been able to create an account and login using Firebase's email and password auth.
The problem is, I don't know how to take the next step to separate each user's data — I want each user to only to be able to change their own data, and show nothing until they're logged in.
The only thing I could think of was to change the firebase URL I'm using to separate the FirebaseArrays I'm using, but that seems super hacky and didn't work when I tried it.
How am I supposed to use the unique uids to create separate, individual user data?
So every user will have a unique id within the authorize table , of which you cannot directly access ( in that you cannot add tables - firebase keeps it locked down for security reasons )
This still allows for a separation based on the id. There will essentially be a books array, You could add an array of users on each book, but that could get redundant. I think the best solution would be to create a user_books array. This will list all the users by id that have books, with the bookID as a nested array
user_books
-Jsdee23dnn23d2n3d
|- sdfEDASED82342dsd : true
|- SDEdsdfwer343dsdf : true
-Jsdeesdfffffs433
|- 43334sdfsrfesrdfg : true
|- sdfsf333fsdfsrrrr : true
This connects the books to the users. So each user has an array of books . This is the target to access when you want the user to perform CRUD operations
var usersRef = new Firebase('https://test.firebaseio-demo.com/user_books');
var ref = usersRef.child('userID');
When you create a book you will need to update both the book table and the user_books table with the selected user(s) associated to the book
I am working on a CakePHP3 application that will be used to display information about which products our suppliers are currently offering.
** Different Vendors provide their product lists in different ways, CSV, JSON, or by way of a web scrape **
I have 2 models that I have created:
Vendors - This references a specific Vendor that we use.
VendorProducts - This references all the products that all of our vendors offer.
I would like to be able to call something like:
$vendor->getAvailableProducts()
and have it either get the CSV and parse it, grab the JSON, or scrape the suppliers website and use this to populate the VendorProducts table in the database with products from this supplier.
I understand the idea behind Fat Models and Skinny Controllers, however I'm having a bit of difficulty implementing this feature.
I would like to provide the following functionality.
The Vendor's getAvailableProducts() function can be called via the web interface AND/OR a cakephp shell script that could be run in a cron job.
As some functionality (like scraping the website) takes a considerable amount of time, I would like to be able to see the progress of this function in the view,
eg: X/Y Products Updated from {Supplier}.
This can be broken down into the following questions:
1. Which file should my "getAvailableProducts()" function go in?
2. As each $vendor has a unique updateProducts() function, how would the correct function be called from $vendor->getAvailableProducts()
// something like this?
public function getAvailableProducts() {
if($vendor->name == "SupplierA") {
getProductsFromSupplierA();
}
if($vendor->name == "SupplierB") {
getProductsFromSupplierB();
}
..., etc.
}
3. How can the progress of this function be returned to a View?
Don't use table classes for that create a new namespace within the model layer or in the app itself:
src/Vendor
src/Model/Vendor
Have a factory that constructs and returns you the Vendor classes:
$vendorA = VendorFactory::get('SupplierA');
$vendorB = VendorFactory::get('SupplierB');
Each vendor class must implement a method fetchProducts(), use an interface or an abstract base class for that.
The method should return a normalized array that can be used to turn the products in entities:
$this->newEntities(VendorFactory::get('SupplierA')->fetchProducts());
You'll have a hard time determining the progress if there is no way to know the total amount of records. Which is likely when you scrape the website. Same issue applies when the API doesn't tell you the total amount of records per JSON data set. If you're able to get that total count somehow you can do this:
$this->newEntities(VendorFactory::get('SupplierA')->fetchProducts([
'limit' => 50,
'offset' => 0
]);
And implement pagination for the vendor which you can then use to run over all the records in a while() loop in chunks of X records. If you trigger that via shell you can create a "job" for that and update the progress after each chunk. There are multiple existing solutions for this kind of task already out there. Finally use Comet or Websockets to get the status updated on your website. Or the old way: Trigger an AJAX request every X seconds to check the status.
There is a lot more that could be said, but this is actually already a very broad question, there is very likely not enough detail to cover all cases. Also it might be possible (I'm pretty sure) there are different ways to solve this.
I am quite new to ACL
The website is about cars where a dealer can have several brands and in several countries.
For example:
Dealer: John Doe
has the brands Audi in UK, and Kia in France.
I have the below models:
- Brand
- Country
- Dealer
- BrandsCountriesDealers (which links the above three together)
The dealer cannot add / edit a brand or a country. He can only add/edit/delete a car in the country that he has access to and to the brand that he owns.
I was wondering if I use a specific foreign key of the BrandsCountriesDealers model as an ACO only and when the dealer adds a car, I check if this car's brand and country are valid by checking the record in the BrandsCountriesDealers model which he has access to ?
I hope this was clear.
Implementing ACL is a bit hard but not impossible. Once you get use to working with ACL you undrestand how easy and powerful it is. It might take some research to configure and learn it but it is really worthed.
I think you should use ACL for certain reasons:
It makes your code very clean and tidy:
You don't need to keep assign
if user logged in do this
or if user type is this do that
Access Level: No need to write validation for each types of user.
High Security: ACL is working with Auth component
each method can be granted to one or more user type (Role)
Almost every thing is stored in DB so your code is clear again
I remember when I started to work with ACL I followed this tutorial. It is in Portuguese language. I don't know this language but I followed step by step and get it worked.
http://www.youtube.com/watch?v=EIjfwqqGRhs
I am new in extjs4 .I am using MVC structure.and I am going to save associated data to server side.I am getting stuck at this point.
I have two tables
1)
Question
========
qid
question
2)
Option
========
oid
option
qid
I am going to displayQuestion answer page. There are 10 questions diplays on the page at a time with their 4 options for each question.
I know how to save single instance of model in to database.
var check = Ext.ModelManager.create(
{
question:que,
}, 'Bal.model.sn.QuestionModel');
check.save();
I am getting all the selected questions with there options.but I dont know how to save associated data to database.And how to create instance of particular models to instantiate model with data..
Here is my other model
'Bal.model.sn.optionModel'
How can i solve this issue...
This functionality is not provided out of box. Please take a look at this thread for some implementations of similar functionality: http://www.sencha.com/forum/showthread.php?141957-Saving-objects-that-are-linked-hasMany-relation-with-a-single-Store/page4