
    Michael B. GEISLER, Appellant, v. CITY COUNCIL OF the CITY OF CEDAR FALLS, Iowa, Appellee.
    No. 07-0474.
    Supreme Court of Iowa.
    July 10, 2009.
    
      D. Raymond Walton of Beecher Law Offices, Waterloo, for appellant.
    Susan Bernau Staudt, Cedar Falls, for appellee.
   BAKER, Justice.

This appeal arises out of a petition for writ of certiorari filed by the appellant, Michael Geisler, against the appellee, the City Council of Cedar Falls. Geisler challenged the district court’s dismissal of his claims that the City (hereinafter referred to as “the City”) acted illegally in denying his proposed site plan for the development of real estate in the College Hill Neighborhood Overlay Zoning District (hereinafter referred to as “the Overlay District”) and its subsequent enactment of a six-month moratorium on development in the Overlay District. The district court dismissed Geisler’s claim that the moratorium was illegal on a motion to dismiss. Subsequently, on a motion for summary judgment, the court dismissed his remaining claim that the City acted illegally in denying approval of Geisler’s site plan for the project because the ordinance that ultimately prohibited the project was under discussion at the time of Geisler’s initial application.

The City has asserted that its issuance of the moratorium was a legislative function, and therefore, it is not reviewable by a writ of certiorari because certiorari review is only available when the lower tribunal is acting in a quasi-judicial capacity. We find the City’s adoption of a moratorium is a legislative function and, therefore, not reviewable. We also find that the district court applied incorrect law in determining whether the City illegally denied Geisler’s site plan and failed to consider whether the change in zoning was done in bad faith. Because the district court erred in granting summary judgment based upon an incorrect standard, we reverse and remand for further proceedings consistent with this opinion.

I. Background Facts and Prior Proceedings.

In 2004, Geisler purchased real estate located in the Overlay District of Cedar Falls, Iowa, for the purpose of developing an eight-unit apartment complex. In May of 2005, he submitted a site plan for redevelopment of the land to the Cedar Falls Planning and Zoning Commission. At the Commission’s May 18, 2005, meeting, city planner Martin Ryan stated that the site plan met all the basic ordinance requirements. However, there was a large amount of resident opposition to the proposed development, and the Commission voted to deny approval of Geisler’s site plan.

The regular Cedar Falls City Council meeting was held on May 23, 2005. At the meeting, the Council considered Geisler’s proposed site plan. Several Overlay District residents expressed concerns about the plan, including the increase in traffic it would generate and the detrimental effect to single-family homes in the area. The Council denied the site plan under Cedar Falls City Ordinance No. 29 — 160(f) because it was “inconsistent with the character of the neighborhood due to architectural design ... [and was] not of comparable scale and character in relation to adjoining properties.” Under the ordinance in effect in May of 2005, the Council had the discretion to determine whether the site plan was compatible with surrounding buildings.

At the May 28, 2005, meeting, a motion also passed to discuss a temporary moratorium to study the issue of multi-family unit construction in the Overlay District. At the next City Council meeting on June 13, 2005, the City Council passed a resolution imposing a moratorium on all development or construction of multi-family housing in the Overlay District.

Also on this date, Geisler submitted a revised site plan to the City Department of Development. It was not processed in time to be discussed at the meeting. Later, on July 11, 2005, a city official refused to consider Geisler’s revised site plan, effectively denying the project. After further study of a proposed zoning amendment, the City Council passed a resolution on December 12, 2005, down-zoning the Overlay District, prohibiting all development or construction of multi-family housing. Geisler did not resubmit the site plan after the enactment of the ordinance.

On June 22, 2005, Geisler filed a petition for writ of certiorari in the district court alleging that the City acted illegally by denying his site plan and subsequently passing the moratorium on development in the Overlay District. The petition stated these were illegal acts and an unconstitutional taking of his property for public use without just compensation. On July 25, 2005, the City filed a motion to dismiss Geisler’s petition for lack of subject matter jurisdiction.

On February 6, 2006, the district court issued an order overruling in part and granting in part the City’s motion to dismiss. The trial court overruled the City’s motion with regard to denial of the site plan because the record was not sufficient to conclude the City denied the plan because it intended to impose a moratorium on development. The court granted the City’s motion as to Geisler’s claim that the City acted illegally in imposing the moratorium, ruling the City was within its legislative authority to do so. Subsequently, the City filed a motion for summary judgment on the remaining claim, which the court granted because the December 2005 ordinance that prohibited the project was under discussion at the time Geisler submitted his initial site plan in May 2005. Geisler appeals.

II. Scope of Review.

Our review of the judgment entered by the district court in a certiorari proceeding is governed by the rules applicable to appeals in ordinary actions. Iowa R. Civ. P. 1.1412.

The moratorium issue comes to us from the district court’s grant of a motion to dismiss. A court can grant a motion to dismiss if the plaintiff fails to state a claim upon which any relief may be granted. Iowa R. Civ. P. 1.421(l)(f). On appeal, we review a district court’s ruling on a motion to dismiss for correction of errors at law. See Iowa R.App. P. 6.907 (2009); see also Mlynarik v. Bergantzel, 675 N.W.2d 584, 586 (Iowa 2004). A court cannot consider factual allegations contained in the motion or the documents attached to the motion. Berger v. Gen. United Group, Inc., 268 N.W.2d 630, 634 (Iowa 1978). The court must ignore these facts, except those of which the court may take judicial notice. Winneshiek Mut. Ins. Ass’n v. Roach, 257 Iowa 354, 365, 132 N.W.2d 436, 443 (1965). In determining whether to grant the motion to dismiss, a court views the well-pled facts of the petition “in the light most favorable to the plaintiff with doubts resolved in that party’s favor.” Haupt v. Miller, 514 N.W.2d 905, 911 (Iowa 1994). The purpose of the motion is to test the legal sufficiency of the petition. Berger, 268 N.W.2d at 634.

The issue of whether the City illegally denied Geisler’s site plan comes to us on appeal from a ruling on a motion for summary judgment.

Summary judgment is appropriate when there is no genuine issue of material fact and the moving party is entitled to judgment as a matter of law. The burden is on the moving party to establish there is no genuine issue of material fact, and the facts must be viewed in the light most favorable to the nonmoving party.

Rodda v. Vermeer Mfg., 734 N.W.2d 480, 483 (Iowa 2007).

III. Merits.

A. Legality of Moratorium. The City claimed that a writ of certiorari is an improper remedy for challenging the moratorium, as the district court lacked subject matter jurisdiction over the legislative actions of the Cedar Falls City Council. The City contended that the issuance of a moratorium is a legislative function. Geis-ler disputed that a moratorium is a legislative function, asserting that it is a judicial function. He also asserted that the City acted illegally in imposing the moratorium.

In granting the motion to dismiss, the district court noted that the City “was within its legislative authority and discretion in issuing its development moratorium.” In his resistance to the City’s motion to dismiss, Geisler did not raise, and the court did not rule on his current claim, that in passing the moratorium, the City failed to follow procedures required by Iowa Code section 414.4 and the City’s zoning ordinance. Because Geisler failed to raise this issue in his resistance, we do not address this claim. See State v. McCright, 569 N.W.2d 605, 607 (Iowa 1997) (“Issues not raised before the district court, including constitutional issues, cannot be raised for the first time on appeal.”). We are, therefore, confronted only with the issue of whether the enactment of a moratorium is a legislative function and Geisler’s challenge to the City’s authority to enact the moratorium.

A writ of certiorari will not lie against the City if it was exercising a legislative function at the time it enacted the moratorium; such actions are not reviewable by the courts. Stream v. Gordy, 716 N.W.2d 187, 191 (Iowa 2006). This rule arises from the traditional separation of powers between the three branches of government. “The chief characteristic of the legislative function is the determination of broad policies or principles for the conduct of society’s affairs.” Goodell v. Humboldt County, 575 N.W.2d 486, 493 (Iowa 1998). We have long held that an amendment of a zoning ordinance is a legislative function. Boomhower v. Cerro Gordo County Bd. of Adjustment, 163 N.W.2d 75, 77 (Iowa 1968).

In enacting the moratorium until a revised zoning ordinance could be reviewed, the City was performing a traditional legislative function. Brown v. Crawford County, 960 F.2d 1002, 1012 (11th Cir.1992); Jackson Ct. Condos., Inc. v. City of New Orleans, 874 F.2d 1070, 1076 (5th Cir.1989). A moratorium aids a governing body in performing the legislative task of municipal planning. See Schafer v. City of New Orleans, 743 F.2d 1086, 1090 (5th Cir.1984) (“Interim development controls such as this moratorium have been found to play an important role in municipal planning. They aid in ‘bridging the gap between planning and its implementation into legal measures.’ They may, as here, be used to preserve the status quo while study of the area and its needs is completed. This moratorium on land use serves a significant public purpose.” (quoting 3 Patrick J. Rohan, Zoning and Land Use Controls § 22.01, at 22-2 (1984))).

To the extent Geisler disagrees with the City’s exercise of this legislative function, his recourse is “review by the electorate at the next election.” Stream, 716 N.W.2d at 192. We hold a writ of certiorari will not lie to review the action of the City in imposing the moratorium because it was exercising a legislative function.

B. Legality of Site Plan Denial. In his original petition, Geisler also challenged the City’s denial of his proposed site plan. There was a change in the Overlay District’s zoning ordinance from the time Geisler submitted his project and it was denied in May of 2005, to the time the City’s refusal to approve his site plan was reviewed by the district court. The district court granted summary judgment to the City on Geisler’s claim that the City illegally denied his site plan. In granting the City’s motion for summary judgment, the district court applied what has been referred to as the pending ordinance rule concluding that “at the time the site plan was denied there was pending concern, discussion and intention to amend the zoning ordinance and the site plan was denied for reasons that fueled the moratorium and zoning changes.” Because the district court believed there was a pending ordinance at the time of Geisler’s application, the court applied the new ordinance in effect at the time of the court’s decision, which ordinance prohibited multi-family housing, and found the City’s denial was appropriate. We must determine whether the district court was correct in applying the pending ordinance rule to Geisler’s claim. Contrary to the pending ordinance rule applied by the district court, we have adopted the rule that “ ‘a reviewing or appellate court must decide a case based on the zoning law as it exists at the time of the court’s decision.’ ” U.S. Cellular Corp. v. Bd. of Adjustment, 589 N.W.2d 712, 717 (Iowa 1999) (quoting Edward H. Zeigler, Rathkopf s The Law of Zoning and Planning § 26.02[2][a], at 26-3 to 26-4 (4th ed.1996)). We do not retreat from that position.

Under the rule adopted in U.S. Cellular, the district court should have applied the new zoning ordinance that was passed on December 12, 2005, in determining the legality of the City’s denial of Geisler’s site plan, unless an exception to this rule applied.

We have recognized two exceptions to the rule that the reviewing court applies the law in effect at the time of its review. Id. at 718. First, a developer may acquire a vested right because of substantial expenditures made in reliance on the previously existing ordinance, thereby precluding application of the new ordinance. Id. Second, a reviewing court will not apply a new ordinance if officials acted in bad faith by denying or delaying approval of a properly submitted and conforming site plan in order to alter a zoning ordinance to bar the prospective development. Id. at 717.

We have previously discussed the substantial expenditure exception. In Quality Refrigerated Services Inc. v. City of Spencer, 586 N.W.2d 202 (Iowa 1998), we noted that an affected landowner may acquire vested rights under certain circumstances:

The only vested right that a property owner may acquire is the right to complete the development of his property in accordance with his plans as of the effective date of the new ordinance....
To determine whether a property owner has acquired a vested right, we engage in a two-part analysis: (1) did the property owner make substantial expenditures toward the use in question prior to the zoning change; and (2) were the expenditures made by the property owner lawful.

Quality Refrigerated Servs., 586 N.W.2d at 206 (emphasis added) (citations omitted); see also Keller v. City of Council Bluffs, 246 Iowa 202, 212-13, 66 N.W.2d 113, 119 (1954). We held that without the required building permit, the landowner’s expenditures were illegal and, therefore, could not be relied upon to acquire a vested right. Quality Refrigerated Servs., 586 N.W.2d at 207.

At the point when Cedar Falls rezoned Geisler’s property, effectively stopping the project, no building permit had been issued. Because only expenditures made pursuant to a validly-issued permit will support the vested rights exception, U.S. Cellular, 589 N.W.2d at 718, Geisler had acquired no vested rights and cannot rely upon this exception.

We also discussed the bad-faith exception in U.S. Cellular. The Board of Adjustment for the City of Des Moines denied U.S. Cellular’s request to construct a cell phone tower in an area that permitted such use but required a special permit. Id. at 714. After the site plan’s denial, the Board rezoned the area to prohibit the requested use. Id. at 715 n. 2. This court affirmed the ruling of the district court finding bad faith on behalf of the Board. Id. at 718-19. To find bad faith, we required illegality of the denial coupled with an improper purpose. Id.

In the context of a zoning decision, “ ‘[a]n illegality is established if the board has not acted in accordance with a statute; if its decision was not supported by substantial evidence; or if its actions were unreasonable, arbitrary, or capricious.’ ” Perkins v. Bd. of Supervisors, 636 N.W.2d 58, 64 (Iowa 2001) (quoting Norland v. Worth County Compensation Bd., 323 N.W.2d 251, 253 (Iowa 1982)). In U.S. Cellular, we found that the application was denied without any legal justification even though it met all of the requirements of the then existing ordinance. U.S. Cellular, 589 N.W.2d at 718-19. We specifically noted that the Board’s professed reasons for denial were not based on either the ordinance in effect at the time of application or the ordinance that was subsequently passed. Id. at 718. Further, the Board misrepresented both the facts allegedly supporting the application’s original denial and the facts allegedly supporting the change in ordinance. Id. Under those circumstances, we found the Board’s actions “patently illegal.” Id.

Of course, not every erroneous denial of a permit is done in bad faith. The deci-sionmaker must act with an improper purpose for the denial to be in bad faith. See id. at 717. The Board’s improper purpose in U.S. Cellular was illegally denying the application to produce a delay thereby giving the Board time “to enact the new ordinance prohibiting the requested use.” Id. at 719.

Other states have discussed the issue of what constitutes an improper purpose in finding bad faith. Certain examples are clear, such as punishing a political opponent or denying a barber shop license to protect the decisionmaker’s competing shop. Brady v. Town of Colchester, 863 F.2d 205, 216 (2d Cir.1988); Wilkerson v. Johnson, 699 F.2d 325, 328-29 (6th Cir.1983). Other examples are less clear. In New Jersey, the court found bad faith because, after concluding the change in the zoning ordinance seemed to bear no relation to public health, safety, morals, or general welfare and was arbitrary, it found the change was “for no other purpose than to preclude a use which for seventeen years has been lawful.” Brown v. Terhune, 125 N.J.L. 618, 18 A.2d 73, 74 (1941).

Courts have also found bad faith when municipalities attempt “to zone out a use” or stop a particular project. State ex. rel. Humble Oil & Refining Co. v. Wahner, 25 Wis.2d 1, 130 N.W.2d 304, 311 (1964). In Humble Oil, this conclusion was based upon the fact that “town officials were trying to keep one jump ahead of Humble and were attempting to change the rules after they had been hailed into court” by Humble. Id. From these cases, it can be discerned that an improper purpose exists when a zoning authority adopts a new zoning regulation designed to frustrate a particular applicant’s plans for development.

We find that the district court erred in relying on the pending ordinance rule rather than applying the legal principles set out in U.S. Cellular. Because the district court did not consider whether the site plan denial was done in bad faith, we remand the issue of bad faith to the district court to determine whether the City illegally denied the site plan and whether an improper purpose existed. We note that the court has the ability to take additional evidence on this issue. See Iowa R. Civ. P. 1.1410.

IV. Disposition.

We conclude that the City’s adoption of a moratorium is a legislative function and, therefore, not reviewable. We also find that the district court erred in awarding summary judgment on the denial of Geis-ler’s site plan because the district court applied incorrect law in determining whether the City illegally denied Geisler’s site plan and failed to consider whether the denial was done in bad faith. We therefore remand this case for further proceedings consistent with this opinion.

AFFIRMED IN PART, REVERSED IN PART, AND REMANDED. 
      
      . It appears the district court applied the minority view that the rights of the parties are governed by the ordinance in effect at the time of application, so a later amendment of the ordinance does not apply on appeal, unless at the time the application was filed a zoning change was pending. See Arden H. Rathkopf et al., 3 Rathkopfs The Law of Zoning and Planning §§ 37:7-8, at 37-11 to 37-12 (2004). This exception is known as the pending ordinance rule. Id. § 37:8, at 37-12. We rejected the minority view in U.S. Cellular, 589 N.W.2d at 718.
     
      
      
        . If there were valid grounds for denial of the application, for example, the proposed site plan did not comply with the ordinance requirements, then there would be no factual basis for finding a bad-faith denial even if the denial also happened to further the decision-maker’s subjective desire to prevent the proposed use.
     
      
      . Unlike the above situations where bad faith was found when the governing body sought to change the rules in response to a particular request, the result may be different where a zoning change is already being contemplated before the particular request is made. The fact that a zoning amendment is pending or under study may be a factor in determining the existence of bad faith. Kittery Retail Ventures, LLC v. Town of Kittery, 856 A.2d 1183, 1192-93 (Me.2004).
     