Creating a form to send multiple emails to existing emails using Rails - ruby-on-rails-3

I'm building an order management system for customers. I need to set it up so I can build a form that emails a brief of the order status to a customer. The trick is that a customer can have multiple emails i.e no limits on that and the form I need to set up would show the brief generated in a textbox(nothing hard there) as well as a list of checkboxes with the email addresses which to send to.
Clicking on/off the checkboxes determines which addresses would the brief be sent to. I have everything worked out except for one main thing i.e the form - I'm not sure how can I actually set this part up i.e I'm using simple_form here and I'm not sure which model would I be making the form against? Do I need to build another model here? I'm pretty stuck.

May be you can create model like Email without database and use all ActiveRecord helper methods. These articles may be helpful.
http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
http://railscasts.com/episodes/193-tableless-model?view=asciicast

Related

Is it possible to restrict part of an Ektron smart form to a specific user group?

Is it possible to restrict part of a smart to only a certain user group and if the user trying to edit the smart form content is not of that group, then the user cannot change that portion of the content?
Example:
Let's say I have an Employee smart form with fields for EmployeeBio, EmployeeHireDate, and EmployeeDept. Would it be possible to allow the general author user group to be able to edit the EmployeeBio field, but restrict the EmployeeDept and EmployeeHireDate fields to only an HRAdmin user group?
If it helps, I am using Ektron 9.00 SP3.
As far as I know, you either can edit a content block or you can't; there isn't a way to subdivide permissions on a per-smartform-field basis.
What you can do, is group the "restricted" fields into their own smartform, and then reference that via a content resource selector field.
So your Employee smart form might look like this:
/root/txtName (not in your example, I know...)
/root/rtfBio
/root/cresHRID
Side note: I'm using hungarian notation on my field names here. txt indicates a plain text field, rtf indicates a rich text (html) field, and cres indicates a content resource selector.
Then you could have a second smart form... let's call it "EmployeeHR", and it would have the following structure:
/root/hireDate
/root/txtDepartment
That would, in theory, work. However, I must say that I really don't like splitting up this particular type of data in this way. First, department feels like it would function better as a taxonomy to which you could add the content block. Second, it feels like this type of data would be better served by housing it outside of ektron and then using a DxH (Digital Experience Hub) connector to bring the data into Ektron. This way the external system could handle permissions at a more granular level, and you would still have access to the data within Ektron for use elsewhere within the site.
UPDATE
As I ponder this question some more, another option comes to mind. You could write an ASPX page or UserControl that checks to make sure you're logged in and a member of a particular group before presenting you with a custom edit screen. The following code will check if the current user is a member of the admin group; you can swap out a different group id to fit your needs:
// Not sure off hand which of these using statements provides access to EkConstants...
using Ektron.Cms;
using Ektron.Cms.Common;
using Ektron.Cms.Content;
var userGroupApi = new Ektron.Cms.Framework.User.UserGroupManager();
var isInGroup = userGroupApi.IsUserInGroup(currentUserId, EkConstants.g_AdminGroup);
This could be implemented as an ASPX page on your site, or it could be implemented as a widget and placed on the user's Smart Desktop tab of the workarea. Either way, you have a lot of options for getting what you want, just nothing "out of the box".

How to show all mails with no restriction of user?

I am in need of showing "All Mails" that have been transacted in OpenERP 7 with no restrictions.
There seems to be some restrictions done when records are fetched from Database(postgresql).
Is there a way to show all the records available in postgresql directly?
Their are several ways, you can use any of below:
You can create Separate menu without any domain on mail.message object which will show you all the messages.
Also you can create the postgres view report for more statistical information on mail.message object this will be tricky and long but informative in future.
Or Even you can remove the Domain from the existing Email menu action to show all the record without any restriction.
Thank You

Linking actions on two tables

Sorry the title isn't very descriptive, but here is what I'm trying to do:
I am making a website that handles student group funding requests. A particular request for funding could involve any number of items. I have two tables: requests and items. A group begins a request by filling out a "request" form, which contains a brief summary of the request, a category (speaker, advertising, etc.), and some other fields necessary for the bureaucratic process. That works fine and was handled pretty much entirely by scaffolding. The problem I'm having is with the "items". I would like the user to click the "submit" button on the new request form and be taken to another page at which he can add any number of items to the items table, all containing in a field the id of the request he just submitted.
The front end appearance doesn't really matter - it could all be on one page - what's important is that the user submits information to one table and then submits information to a second table, with the info sent to the second table containing something that connects it to the information just submitted to the first table.
As you can probably guess, I'm pretty new at rails (I went through the book Head First Rails and I'm working on my first project), so I'm looking for a general explanation about how this can be accomplished.
I recommend you to read / watch this tutorial. It is quite good.
UPDATE:
http://railscasts.com/episodes/196-nested-model-form-part-1
Hope it helps.

Forms in Ruby on Rails

Ive recently started using Ruby on Rails for a project of mine and have hit some interesting walls. Im using scaffolding but instead of moving to the default show page after i have entered data, i want to instead redirect to another page i have created.
The key is the page is another form and half of that form is made up of values entered in the previous form. So ive guessed that i have to keep that in memory instead of allowing it to be written to the database. My original idea was to query the table and find the last record but with multiple users its probably not advisable.
Can anyone help? Examples would be great or even just to point me in the right direction
Im pretty familier with C++, jave etc, so i understand computer jargon.
thanks
Do you care if the data from the first form is stored in the database before going to the second form? If not you can just set the create action in the controller to redirect to the new page you want. Depending on how you are managing the user session, you could then pull up the information the user stored in the first form. For example if you were using Devise to handle the session, you could have the user enter their username, email and password in the first form, then redirect to a profile form that has a separate email option. You could pre-populate the field to show the user.email, but give the user the option to create a separate email for their profile. In your new action for your profile you would just add #profile.email = current_user.email. Keep in mind, this will allow the user to edit this field separate for both tables.
If you want the data entered in the two forms to point to the same database table, I would recommend looking at using nested attributes. This way, you do not have an email columns in separate tables. Railscasts has a pretty good episode on how to do this. http://railscasts.com/episodes/196-nested-model-form-part-1
You can store all entered in the first form data in session. After redirect you can fill all form inputs from stored data in session and then clear that session data.

How to decide whether to split up a VB.Net application and, if so, how to split it up?

I have 2 1/2 years experience of VB.Net, mostly self taught, so please bear with me if I seem rather noobish still and do not know some of the basics. I would recommend you grab a cup of tea before starting on this, as it appears to have got quite long...
I currently have a rather large application (VB.Net website) of over 15000 lines of code at the last count. It does not do retail or anything particularly complex like that - it is literally just a wholesale viewing website with admin frontend, catalogue / catalogue management system and pageview system.
I don't really know much about how .Net applications work in the background - whether they are all loaded on the same thread or if each has its own thread... I just know how to code them, or at least like to think I do... :-)
Basically my application is set up as follows:
There are two different areas - the customer area and the administration frontend.
The main part of the customer frontend is the Catalogue. The MasterPage will load a list of products but that's all, and this is common to all the customer frontend pages.
I tend to work on only one or several parts of the application at a time before uploading the changes. So, for example, I may alter the hierarchy of the Catalogue and change the Catalogue page to match the hierarchy change whilst leaving everything else alone.
The pageview database is getting really quite large and so it is getting rather slow when the application is first requested due to the way it works.
The application timeout is set to 5 minutes - don't know how to change it, I have even tried asking this question on here and seem to remember the solution was quite complex and I was recommended not to change it, but if a customer requests the application 5 minutes after the last page view then it will reload the application from scratch. This means there is a very slow page load whenever it exceeds 5 minutes of inactivity.
I am not sure if this needs consideration to determine how best to split the application up, if at all, but each part of the catalogue system is set up as follows:
A Manager class at the top level, which is used by the admin frontend to add, edit and remove items of the specified type and the customer frontend to retrieve a list of items of the specified type. For example the "RangeManager" will contain a list of product "Ranges" and will be used to interact with these from the customer frontend.
An Item class, for example Range, which contains a list of Attributes. For example Name, Description, Visible, Created, CreatedBy and so on. The form for adding / editing loops through these to display relevant controls for the administrator. For example a Checkbox for BooleanAttribute.
An Attribute class, which can be of type StringAttribute, BooleanAttribute, IntegerAttribute and so on. There are also custom Attributes (not just datatypes) such as RangeAttribute, UserAttribute and so on. These are given a data field which is used to get a piece of data specific to the item it is contained in when it is first requested. Basically the Item is given a DataRow which is stored and accessed by Attributes only when they are first requested.
When one item is requested from a specific manager is requested, the manager will loop through all the items in the database and create a new instance of the item class. For example when a Range is requested from the RangeManager, the RangeManager will loop through all of the DataRows in the Ranges table and create a new instance of Range for each one. As stated above it simply creates a new instance with the DataRow, rather than loading all the data into it there and then. The Attributes themselves fetch the relevant data from the DataRow as and when they're first requested.
It just seems a tad stupid, in my mind, to recompile and upload the entire application every time I fix a minor bug or a spelling mistake for a word which is in the code behind (for example if I set the text of a Label dynamically). A fix / change to the Catalogue page, the way it is now, may mean a customer trying to view the Contact page, which is in no way related to the Catalogue page apart from by having the same MasterPage, cannot do so because the DLL is being uploaded.
Basically my question is, given my current situation, how would people suggest I change the architecture of the application by way of splitting it into multiple applications? I mean would it be just customer / admin, or customer / admin and pageviews, or some other way? Or not at all? Are there any other alternatives which I have not mentioned here? Could web services come in handy here? Like split the catalogue itself into a different application and just have the masterpage for all the other pages use a web service to get the names of the products to list on the left hand side? Am I just way WAY over-complicating things? Judging by the length of this question I probably am, and it wouldn't be the first time... I have tried to keep it short, but I always fail... :-)
Many thanks in advance, and sorry if I have just totally confused you!
Regards,
Richard
15000 LOC is not really all that big.
It sounds like you are not pre-compiling your site for publishing. You may want to read this: http://msdn.microsoft.com/en-us/library/1y1404zt(v=vs.80).aspx
Recompiling and uploading the application is the best way to do it. If all you are changing is your markup, that can be uploaded individually (e.g. changing some html layout in an aspx page).
I don't know what you mean here by application timeout, but if your app domain recycles every 5 minutes, then that doesn't seem right at all. You should look into this.
Also, if you find yourself working on various different parts of the site (i.e. many different changes), but need to deploy only some items in isolation, then you should look into how you are using your source control tools (you are using one, aren't you?). Look into something like GIT and branching/merging.
Start by reading:
Application Architecture Guide