views

How to unit test django views? Or maybe and MVT question.

I've been using django for a couple months now and I'm starting to get comfortable with it. At this point in my development I want to begin integrating unit testing and I've discovered unit testing a view to be tricky because of the way that django implements views with functions. For example, each function is a view/page in django if t...

Drupal: replacing field value in View

I have Drupal 5 View (must be "Views 1" so), which contains Event_StartTime field, which shows up normally for the fields that have a real date inside. But I also have a number of records with Event_StartTime field value like Dec 31 1969 - 8:00pm which looks bad in view and I need to replace them with some custom label, like "No Date Ava...

How does one extract the definition of a view using standard SQL?

In trying to answer this question for myself I came across this nugget, after eventually adding "oracle" to my query terms: select DBMS_METADATA.GET_DDL('TABLE','<table_name>') from DUAL; Which works, but is not portable. How do I do the same thing on MySQL? SQLite? Others? ...

Limiting the view of certain page elements to only the owner of the profile?

I have a user model and a profile model. user has_one :profile profile belongs_to :user On the "show" view of the profile, there's an input field that only the owner of the profile should see. I currently have it limited to where only a logged-in user can see it, but I need it to go further and only appear visible to the user who owns...

Drupal Views: difference between Filters and Arguments?

What difference between Filters and Arguments? E.g. if I need to show nodes where event_start is located inside specified month, which one should I use? ...

Is there a way to write a single expression over multiple lines in haml?

I have this in one of my haml views: -form_for :news_item_comment, :url=>{:id => comment.id, :controller => 'comment' , :action => 'add_comment'}, :html => {:id => "form-#{comment.id}"} do |f| ... Since it's really long and hard to read I want to split it over 2 lines. Is there anyway to do this without violating haml's whites...

How Would I Change ASP.NET MVC Views Based on Device Type?

I'm working my way through some ASP.NET MVC reading and I have a web app at work that I'll be migrating from WebForms to MVC. One of the feature requests I expect to get in the process is to have a simplified view returned if the user is coming from a mobile device. I can't quite see where the best place is to implement that type of ...

Changing drupal view filter from greater than to less than

I have a drupal view I've created for events, each event has a date field I'd like to create a way either in the view itself or via the API to have an option for users to select all events, past events or future events. I've created a basic filter event_date > now which works, however I can't seem to change this to event_date < now via t...

DRYing Views in Rails (number_to_currency)

I have code similar to: number_to_currency(line_item.price, :unit => "£") littering my views in various models. Since my application deals only in GBP (£), should I not move this into each of my models so that line_item.price returns the string as it should be (i.e. number_to_currency(line_item.price, :unit => "£") and line_item.price ...

Weird OpenEdge query behaviour

We have recently had to do some work with an OpenEdge database that a third party product uses, and today (after much hair-pulling), we finally identified why a view was returning no results. This view in question combines about 100 separate tables, and is then queried against (we have limited rights to this database). One of the fields ...

How can I aggregate two classes of values in a SQL query?

I have a table that contains intervals: CREATE TABLE tbl ( user_id: INTEGER, start: TIMESTAMP, end: TIMESTAMP, billable: BOOLEAN ); I want to create a view that looks like this: user_id | billable_time | unbillable_time I can get one of these two using a query like this: SELECT user_id, sum(end - start) AS billable...

SQL Server 2005 View vs Materialized View vs Stored Procedure

If I have a table that contains tens of thousands of records of accounts for multiple locations. Is there any speed difference if I query a view that selects all accounts for a specific location and a stored procedure that with the same SQL statement? EDIT: I ran across this Materialized View. It seems like this would always be used. ...

ASP.NET MVC - Passing a Model referencing a different assembly from a Controller to a View using C#

Given two assemblies: project.web project.lib The project.web assembly references project.lib which contains some business logic. A simple class from project.lib: public class Person { public string Name; } In project.web.Controllers: Using project.lib.models; public class PersonController : Controller { Person perso...

How to sort a view using Drupal Fivestar average ratings?

I am using Drupal 6.13, Views 6.x-2.6, Voting API 6.x-2.3, Fivestar 6.x-1.18. I have a content type with field of type Fivestar Rating. I have a view where my intention is to list all of the nodes with this content type sorted in descending order by the overall average rating. The view is working in that it is showing the correct info...

MySQL Certification Guide Practice Qn - Views' Column Names

the question is Which of the following methods for providing explicit names for the columns in a view work? a. Include a column list b. Provide column aliases in the view SELECT statement c. Rename the columns when you select from the view answer a. Works: Include a column list b. Works: Provide column aliases in the view SELECT stat...

Accessing views with absolute paths on ASP.NET MVC

I'm trying to access a view in this way: return View(@"~\Items\Details.aspx"); and I get this error: The view '~\Items\Details.aspx' or its master could not be found. The following locations were searched: ~\Items\Details.aspx On the ItemsController, in the Details action, returning View() works just fine. Why can't I access t...

is there a better way I can do this? in asp.net mvc

since my app has a sidebar menu that gets built dynamically through an xml everytime I want to load a view I need to pass all of this parameters. ViewData["mainItems"] = navigation.getItems(); ViewData["controller"] = controller;//this is just a string with the name of my controller how can I avoid doing this everytim...

django class view with decorator and sessions

I'm trying to convert some of my django views over from function based views to class based views and I've run into a small problem. My OO is kind of weak and I think the problem is that I've lost track of where things are going. I have a custom login decorator that I need on the views so I have... First I have the View class from thi...

CakePHP views question

I am working on a project using CakePHP and have been trying to update some views. The file uploads to the server correctly but the system seems to serve the old version. I am kind of new to Cake so I'd appreciate any pointers. Thanks! ...

Can I disable auto formatting in vs2008?

How can I disable auto formatting for views (html files) in vs2008? ...