问:
How to order an array only after it has been filled
```<code>   func getOkToDownload(response:AcloseCarsToDownload?, error : Error?) -> Void {

        if let response = response {
           self.response = response
            if response.status == "OK" {
                if let carsDownloaded = response.cars {
                    var number = numberCars / (categories?.count)!
                    number = number == 0 ? 1 : number

                 let sortedArray = carsDownloaded.sorted {
                            distance(from: currentLocation!, to: $0.location!) < distance(from: currentLocation!, to: $1.location!)
                    }

                /*    let firstPlace = sortedArray.prefix(1) */

                  cars.append(contentsOf: sortedArray.prefix(number))

            }
               self.tableView?.reloadData()
            } else {
                let alert = UIAlertController.init(title: "Error", message: response.status, preferredStyle: .alert)
                alert.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil))
                alert.addAction(UIAlertAction.init(title: "Retry", style: .default, handler: { (action) in
                    DispatchQueue.main.async {
                        self.loadPlaces(true)

                    }
                }))
                 self.present(viewController: alert)
                }
            isLoading = false
        }
        else {
            print("response is nil")
        }
    }
</code>```

I'm using this function to create a list cars.append(contentsOf: sortedArray.prefix(number)) of downloaded items from a server; and i want that this list is ordered from nearest to fairest item so i thought to order it by adding

```<code>let sortedArray = carsDownloaded.sorted {
                            distance(from: currentLocation!, to: $0.location!) < distance(from: currentLocation!, to: $1.location!)
                    }
</code>```

but the problem with this solution is that it sorts the list at each call and the result is not the desired one, i wish that only once finished and the array is filled, the list will be ordered. How can i do?

This is the func i used for the call

```<code>func loadCars(_ force:Bool) {

        if !force {
            if !canUpdate() {
                return
            }
        }

         if(force){
        print("load")
        iUpdating = true
         for category in categories! {

            CloseCars.getCloseCars(by: category?.name ?? "berl", coordinates: currentLocation!, radius: radius, token: self.response?.nextPageToken, completion: getOkToDownload)

       }
    }
 }
</code>```

答:
As i said in comment you could count number of responses and compare it with the number of categories, and only then perform your sort function. I haven't tested code, but you could try something like this</p>

```<code>    var counter: Int = 0
var sortedArray: [String] = [] {
    didSet {
        self.tableView.reloadData()
    }
}

func getOkToDownload(response:AcloseCarsToDownload?, error : Error?) -> Void {
    counter += 1
    guard let response = response
        else {
            print("response is nil")
            return
    }
    if response.status != "OK" {return}
    guard let downloadedCars = response.cars else { return }
    allCars.append(contentsOf: downloadedCars)
    if counter != categories.count {return}
    let sortedArray = allCars.sorted {
        distance(from: currentLocation!, to: $0.location!) < distance(from: currentLocation!, to: $1.location!)
    }
}
</code>```

Body:
   func getOkToDownload(response:AcloseCarsToDownload?, error : Error?) -> Void {

        if let response = response {
           self.response = response
            if response.status == "OK" {
                if let carsDownloaded = response.cars {
                    var number = numberCars / (categories?.count)!
                    number = number == 0 ? 1 : number

                 let sortedArray = carsDownloaded.sorted {
                            distance(from: currentLocation!, to: $0.location!) < distance(from: currentLocation!, to: $1.location!)
                    }

                /*    let firstPlace = sortedArray.prefix(1) */

                  cars.append(contentsOf: sortedArray.prefix(number))

            }
               self.tableView?.reloadData()
            } else {
                let alert = UIAlertController.init(title: "Error", message: response.status, preferredStyle: .alert)
                alert.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil))
                alert.addAction(UIAlertAction.init(title: "Retry", style: .default, handler: { (action) in
                    DispatchQueue.main.async {
                        self.loadPlaces(true)

                    }
                }))
                 self.present(viewController: alert)
                }
            isLoading = false
        }
        else {
            print("response is nil")
        }
    }

I'm using this function to create a list cars.append(contentsOf: sortedArray.prefix(number)) of downloaded items from a server; and i want that this list is ordered from nearest to fairest item so i thought to order it by adding

let sortedArray = carsDownloaded.sorted {
                            distance(from: currentLocation!, to: $0.location!) < distance(from: currentLocation!, to: $1.location!)
                    }

but the problem with this solution is that it sorts the list at each call and the result is not the desired one, i wish that only once finished and the array is filled, the list will be ordered. How can i do?

This is the func i used for the call

func loadCars(_ force:Bool) {

        if !force {
            if !canUpdate() {
                return
            }
        }

         if(force){
        print("load")
        iUpdating = true
         for category in categories! {

            CloseCars.getCloseCars(by: category?.name ?? "berl", coordinates: currentLocation!, radius: radius, token: self.response?.nextPageToken, completion: getOkToDownload)

       }
    }
 }

Body:
As i said in comment you could count number of responses and compare it with the number of categories, and only then perform your sort function. I haven't tested code, but you could try something like this

    var counter: Int = 0
var sortedArray: [String] = [] {
    didSet {
        self.tableView.reloadData()
    }
}

func getOkToDownload(response:AcloseCarsToDownload?, error : Error?) -> Void {
    counter += 1
    guard let response = response
        else {
            print("response is nil")
            return
    }
    if response.status != "OK" {return}
    guard let downloadedCars = response.cars else { return }
    allCars.append(contentsOf: downloadedCars)
    if counter != categories.count {return}
    let sortedArray = allCars.sorted {
        distance(from: currentLocation!, to: $0.location!) < distance(from: currentLocation!, to: $1.location!)
    }
}


来源: stackexchange

问:
C++ - constant variable, is it a correct term?
At the end of the artile here: http://www.learncpp.com/cpp-tutorial/45-enumerated-types/

It mentions the following sentence:

Finally, as with constant variables, enumerated types show up in the debugger, making them more useful than #defined values in this regard.

Is "constant variables" a correct term to use? Aren't constants different from variables?

Thanks.

答:
It is an obvious contradiction in terms on the surface, and has probably come about for historical reasons ("variable" being used to refer to a memory location associated with a name and a type).

However, I can try to justify the term:
At compile time, it is an variable - before optimization, it has all the properties a variable has - takes up memory, has a location and so on - and is handled much the same. (In contrast, an value you provide like 43423L, 3.141 or a literal "somestring" is not a variable.)
At runtime, it cannot be changed anymore, and is seen as constant. It's sort of a "write-once variable", which you set in the source.

ContentLicense: CC BY-SA 2.5


问:
Changes on @Input array not detected on child
I have the following angular2 parent:

```<code>ParentComponent {

   some_array : Array;

   (...)

}
</code>```

And its child:

```<code>ChildComponent {

     selector: "child"
     @Input some_object : Object;

}
</code>```

My layout is as follows, from the Parent component:

```<code><ng-container *ngFor="let object of some_array">
     <child [some_object]="object></child>
</ng-container>
</code>```

And Child layout:

```<code><Text [text]="some_object.text"/>
</code>```

The view is rendered accordingly and works perfectly.

However, when I change my object property inside some_array in the parent element via a for loop with [i]ndex, nothing changes in the child element and I need to detect these changes.

How exactly could I do this?

Thank you so much for your help

答:
As long as you haven't actually chosen OnPush as the ChangeDetectionStrategy or detached from ChangeDetection completely, the changes should replicate in your child.

However if you question is how you generally can react to changes of data-bound properties, there is the OnChanges lifecycle hook.

```<code>export class ChildComponent implements OnChanges {

   ngOnChanges(changes: SimpleChanges) {

     if (changes['some_object']) {
       //
       // react to changes in general
       // or access changes['some_object'].currentValue
       // or changes['some_object'].previousValue
       // ...
     }
   }
}
</code>```

Hope this helps to resolve your issue!

ContentLicense: CC BY-SA 3.0

Body:
I have the following angular2 parent:

ParentComponent {

   some_array : Array;

   (...)

}

And its child:

ChildComponent {

     selector: "child"
     @Input some_object : Object;

}

My layout is as follows, from the Parent component:

<ng-container *ngFor="let object of some_array">
     <child [some_object]="object></child>
</ng-container>

And Child layout:

<Text [text]="some_object.text"/>

The view is rendered accordingly and works perfectly.

However, when I change my object property inside some_array in the parent element via a for loop with [i]ndex, nothing changes in the child element and I need to detect these changes.

How exactly could I do this?

Thank you so much for your help

Body:
As long as you haven't actually chosen OnPush as the ChangeDetectionStrategy or detached from ChangeDetection completely, the changes should replicate in your child.

However if you question is how you generally can react to changes of data-bound properties, there is the OnChanges lifecycle hook.

export class ChildComponent implements OnChanges {

   ngOnChanges(changes: SimpleChanges) {

     if (changes['some_object']) {
       //
       // react to changes in general
       // or access changes['some_object'].currentValue
       // or changes['some_object'].previousValue
       // ...
     }
   }
}

Hope this helps to resolve your issue!


问:
Basemap: Plot map similar to WRF domain
I want to plot a figure similar to WRF domain like   having only rectangular frame without any color inside the frame of domain. But, the closest I came was

with the following code:-

```<code>from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import pylab as P

def draw_screen_poly( lats, lons, m):
    x, y = m( lons, lats )
    xy = zip(x,y)
    poly = Polygon( xy,alpha=0.1,edgecolor='k',linewidth=1 )
    plt.gca().add_patch(poly)

lats = [ 26.1238,29.2537,29.2537,26.1238 ]
lons = [82.5228,82.5228, 87.2772,87.2772 ]

m = Basemap(llcrnrlon=80,llcrnrlat=25,urcrnrlon=90,urcrnrlat=30,
              projection='merc', lat_1=27.7,lat_2=60.,lat_0=27.69998,lon_0=85.3,resolution="h")
m.drawcoastlines()
m.drawmapboundary()
m.drawcountries(linewidth=1,color='k')
m.fillcontinents(color='g',lake_color='aqua')
parallels = np.arange(0.,90,1.)
m.drawparallels(parallels,labels=[1,0,0,0],color="gray",fontsize=10)
draw_screen_poly( lats, lons, m )
meridians = np.arange(0.,180.,1.)
m.drawmeridians(meridians,labels=[0,0,0,1],color="gray",fontsize=10)
fig = P.gcf()
P.show()
pngfile = "map_new_domain.pdf".format("avg")
fig.savefig(pngfile)
</code>```

How can I edit my code to get similar figure?

答:
You need to set the facecolor parameter of the Polygon object, this sets the fill colour. I also removed alpha not needed if you want a solid line with no fill.

```<code>poly = Polygon( xy, edgecolor='k', linewidth=2, facecolor='none')
</code>```

Title: Basemap: Plot map similar to WRF domain

Body:
I want to plot a figure similar to WRF domain like   having only rectangular frame without any color inside the frame of domain. But, the closest I came was

with the following code:-

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import pylab as P

def draw_screen_poly( lats, lons, m):
    x, y = m( lons, lats )
    xy = zip(x,y)
    poly = Polygon( xy,alpha=0.1,edgecolor='k',linewidth=1 )
    plt.gca().add_patch(poly)

lats = [ 26.1238,29.2537,29.2537,26.1238 ]
lons = [82.5228,82.5228, 87.2772,87.2772 ]

m = Basemap(llcrnrlon=80,llcrnrlat=25,urcrnrlon=90,urcrnrlat=30,
              projection='merc', lat_1=27.7,lat_2=60.,lat_0=27.69998,lon_0=85.3,resolution="h")
m.drawcoastlines()
m.drawmapboundary()
m.drawcountries(linewidth=1,color='k')
m.fillcontinents(color='g',lake_color='aqua')
parallels = np.arange(0.,90,1.)
m.drawparallels(parallels,labels=[1,0,0,0],color="gray",fontsize=10)
draw_screen_poly( lats, lons, m )
meridians = np.arange(0.,180.,1.)
m.drawmeridians(meridians,labels=[0,0,0,1],color="gray",fontsize=10)
fig = P.gcf()
P.show()
pngfile = "map_new_domain.pdf".format("avg")
fig.savefig(pngfile)

How can I edit my code to get similar figure?

Body:
You need to set the facecolor parameter of the Polygon object, this sets the fill colour. I also removed alpha not needed if you want a solid line with no fill.

poly = Polygon( xy, edgecolor='k', linewidth=2, facecolor='none')


问:
Call program from powershell.exe command and manipulate parameters
I'm trying to call an EXE file program that accepts command line parameters from PowerShell. One of the parameters I'm required to send is based on the string length of the parameters.

For example,

```<code>app.exe /param1:"SampleParam" /paramLen:"SampleParam".length
</code>```

When I run the above, or for example:

```<code>notepad.exe "SampleParam".length
</code>```

Notepad opens with the value 11 as expected.

I would like to achieve the same result when calling PowerShell from cmd / task scheduler.

For example,

```<code>powershell notepad.exe "SampleParam".length
</code>```

But when I do that I get "SampleParam".length literally instead of the "SampleParam".length calculated value.

The expected result was:

running notepad.exe 11

答:
I'd suggest using variables to store your string, etc.

```<code>$Arg1 = 'SampleParam'
## This will try to open a file named 11.txt
powershell notepad.exe $Arg1.Length
</code>```

In your specific example:

```<code>app.exe /param1:$Arg1 /paramLen:$Arg1.Length
</code>```

Utilizing splatting:

```<code>## Array literal for splatting
$AppArgs = @(
    "/param1:$Arg1"
    "/paramLen:$($Arg1.Length)"
)
app.exe @AppArgs
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to call an EXE file program that accepts command line parameters from PowerShell. One of the parameters I'm required to send is based on the string length of the parameters.

For example,

app.exe /param1:"SampleParam" /paramLen:"SampleParam".length

When I run the above, or for example:

notepad.exe "SampleParam".length

Notepad opens with the value 11 as expected.

I would like to achieve the same result when calling PowerShell from cmd / task scheduler.

For example,

powershell notepad.exe "SampleParam".length

But when I do that I get "SampleParam".length literally instead of the "SampleParam".length calculated value.

The expected result was:

running notepad.exe 11

Body:
I'd suggest using variables to store your string, etc.

$Arg1 = 'SampleParam'
## This will try to open a file named 11.txt
powershell notepad.exe $Arg1.Length

In your specific example:

app.exe /param1:$Arg1 /paramLen:$Arg1.Length

Utilizing splatting:

## Array literal for splatting
$AppArgs = @(
    "/param1:$Arg1"
    "/paramLen:$($Arg1.Length)"
)
app.exe @AppArgs


问:
c++11: Array bound is not an integer constant before a token
I have seen this question, but the solution provided there doesn't solve the issue.

```<code>static int num_instances;
std::vector<SomeClass::FunctionWithinTheClass> *mem[num_instances];
</code>```

SomeClass::FunctionWithinTheClass *mem[num_instances]; //Even this raises an error

the value num_instances is obtained by reading a configuration file.

The error I get is :
array bound is not an integer constant before ‘]’ token

This is strange because the value num_instances is fixed at compile time.

答: Even if the value is fixed, it's not a compile time constant, if you want dynamically sized container might I suggest you use stl containers?</p>

Body:
I have seen this question, but the solution provided there doesn't solve the issue.

static int num_instances;
std::vector<SomeClass::FunctionWithinTheClass> *mem[num_instances];

SomeClass::FunctionWithinTheClass *mem[num_instances]; //Even this raises an error

the value num_instances is obtained by reading a configuration file.

The error I get is :
array bound is not an integer constant before ‘]’ token

This is strange because the value num_instances is fixed at compile time.


问:
How do I protect JavaScript files?
I know it's impossible to hide source code but, for example, if I have to link a JavaScript file from my CDN to a web page and I don't want the people to know the location and/or content of this script, is this possible?

For example, to link a script from a website, we use:

```<code><script type="text/javascript" src="http://somedomain.example/scriptxyz.js">
</script>
</code>```

Now, is possible to hide from the user where the script comes from, or hide the script content and still use it on a web page?

For example, by saving it in my private CDN that needs password to access files, would that work? If not, what would work to get what I want?

答:
Good question with a simple answer: you can't!

JavaScript is a client-side programming language, therefore it works on the client's machine, so you can't actually hide anything from the client.
Obfuscating your code is a good solution, but it's not enough, because, although it is hard, someone could decipher your code and "steal" your script.
There are a few ways of making your code hard to be stolen, but as I said nothing is bullet-proof.

Off the top of my head, one idea is to restrict access to your external js files from outside the page you embed your code in. In that case, if you have

```<code><script type="text/javascript" src="myJs.js"></script>
</code>```

and someone tries to access the myJs.js file in browser, he shouldn't be granted any access to the script source.
For example, if your page is written in PHP, you can include the script via the include function and let the script decide if it's safe" to return it's source.
In this example, you'll need the external "js" (written in PHP) file myJs.php:

```<code><?php
    $URL = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    if ($URL != "my-domain.example/my-page.php")
    die("/\*sry, no acces rights\*/");
?>
// your obfuscated script goes here
</code>```

that would be included in your main page my-page.php:

```<code><script type="text/javascript">
    <?php include "myJs.php"; ?>;
</script>
</code>```

This way, only the browser could see the js file contents.

Another interesting idea is that at the end of your script, you delete the contents of your dom script element, so that after the browser evaluates your code, the code disappears:

```<code><script id="erasable" type="text/javascript">
    //your code goes here
    document.getElementById('erasable').innerHTML = "";
</script>
</code>```

These are all just simple hacks that cannot, and I can't stress this enough: cannot, fully protect your js code, but they can sure piss off someone who is trying to "steal" your code.

Update:

I recently came across a very interesting article written by Patrick Weid on how to hide your js code, and he reveals a different approach: you can encode your source code into an image! Sure, that's not bullet proof either, but it's another fence that you could build around your code.
The idea behind this approach is that most browsers can use the canvas element to do pixel manipulation on images. And since the canvas pixel is represented by 4 values (rgba), each pixel can have a value in the range of 0-255. That means that you can store a character (actual it's ascii code) in every pixel. The rest of the encoding/decoding is trivial.

Title: How do I protect JavaScript files?

Body:
I know it's impossible to hide source code but, for example, if I have to link a JavaScript file from my CDN to a web page and I don't want the people to know the location and/or content of this script, is this possible?

For example, to link a script from a website, we use:

Now, is possible to hide from the user where the script comes from, or hide the script content and still use it on a web page?

For example, by saving it in my private CDN that needs password to access files, would that work? If not, what would work to get what I want?

Body:
Good question with a simple answer: you can't!

JavaScript is a client-side programming language, therefore it works on the client's machine, so you can't actually hide anything from the client.
Obfuscating your code is a good solution, but it's not enough, because, although it is hard, someone could decipher your code and "steal" your script.
There are a few ways of making your code hard to be stolen, but as I said nothing is bullet-proof.

Off the top of my head, one idea is to restrict access to your external js files from outside the page you embed your code in. In that case, if you have

<script type="text/javascript" src="myJs.js"></script>

and someone tries to access the myJs.js file in browser, he shouldn't be granted any access to the script source.
For example, if your page is written in PHP, you can include the script via the include function and let the script decide if it's safe" to return it's source.
In this example, you'll need the external "js" (written in PHP) file myJs.php:

<?php
    $URL = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    if ($URL != "my-domain.example/my-page.php")
    die("/\*sry, no acces rights\*/");
?>
// your obfuscated script goes here

that would be included in your main page my-page.php:

<script type="text/javascript">
    <?php include "myJs.php"; ?>;
</script>

This way, only the browser could see the js file contents.

Another interesting idea is that at the end of your script, you delete the contents of your dom script element, so that after the browser evaluates your code, the code disappears:

<script id="erasable" type="text/javascript">
    //your code goes here
    document.getElementById('erasable').innerHTML = "";
</script>

These are all just simple hacks that cannot, and I can't stress this enough: cannot, fully protect your js code, but they can sure piss off someone who is trying to "steal" your code.

Update:

I recently came across a very interesting article written by Patrick Weid on how to hide your js code, and he reveals a different approach: you can encode your source code into an image! Sure, that's not bullet proof either, but it's another fence that you could build around your code.
The idea behind this approach is that most browsers can use the canvas element to do pixel manipulation on images. And since the canvas pixel is represented by 4 values (rgba), each pixel can have a value in the range of 0-255. That means that you can store a character (actual it's ascii code) in every pixel. The rest of the encoding/decoding is trivial.


问:
Add text on right of shinydashboard header
How do I add text to the right of a dashboard header sidebar icon? It seems that previous similar solutions no longer work under updates to dashboardHeader().

This is what I am trying to do in a basic shinydashboard setting:

I can use the strategy from this answer to get text in the header, but it's right-justified (which I can likely fix custom css) and also feels pretty hacky.

```<code>library(shiny)
library(shinydashboard)
ui <- dashboardPage(dashboardHeader(title = "demo",
  tags$li(class = "dropdown",
    tags$p("foo")
  )
), dashboardSidebar(), dashboardBody())
server <- function(input, output) { }
shinyApp(ui, server)
</code>```

Is there a better way to do this?

答:
Adding to Geovany & Tiffany's answers, if you'd like the text content to be dynamic, you can have it change based on user input with the shinyjs::html function.

For example, I'm using it to display the name of the selected tab in the header. You can access the selected tab name in the server function as long as you have given the sidebar menu an id, in my case this is tabs.

I also had to add an id to the div that is appended to the header in Geovany's code, in this case pageHeader.

Then adding this to the server function will change the header text to display the selected tab, with switch being used to create a more presentable header format. Note the useShinyJs() in dashboardPage parameters:

```<code>library(shiny)
library(shinydashboard)

ui <- dashboardPage(
        dashboardHeader(
          title = "demo"
        ),
        dashboardSidebar(),
        dashboardBody(
          tags$head(tags$style(HTML(
            '.myClass {
            font-size: 20px;
            line-height: 50px;
            text-align: left;
            font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
            padding: 0 15px;
            overflow: hidden;
            color: white;
            }
            '))),
          tags$script(HTML('
                           $(document).ready(function() {
                           $("header").find("nav").append(\'<div id="pageHeader" class="myClass"></div>\');
                           })
                           '))
                           ),
        useShinyjs()
)

server <- function(input, output) {
  observeEvent(input$tabs, {
    header <- switch(input$tabs,
                     tab1 = "Tab 1",
                     tab2 = "Tab 2",
                     tab3 = "Tab 3")

    # you can use any other dynamic content you like
    shinyjs::html("pageHeader", header)
  })
}

shinyApp(ui, server)
</code>```

Body:
How do I add text to the right of a dashboard header sidebar icon? It seems that previous similar solutions no longer work under updates to dashboardHeader().

This is what I am trying to do in a basic shinydashboard setting:

I can use the strategy from this answer to get text in the header, but it's right-justified (which I can likely fix custom css) and also feels pretty hacky.

library(shiny)
library(shinydashboard)
ui <- dashboardPage(dashboardHeader(title = "demo",
  tags$li(class = "dropdown",
    tags$p("foo")
  )
), dashboardSidebar(), dashboardBody())
server <- function(input, output) { }
shinyApp(ui, server)

Is there a better way to do this?

Body:
Adding to Geovany & Tiffany's answers, if you'd like the text content to be dynamic, you can have it change based on user input with the shinyjs::html function.

For example, I'm using it to display the name of the selected tab in the header. You can access the selected tab name in the server function as long as you have given the sidebar menu an id, in my case this is tabs.

I also had to add an id to the div that is appended to the header in Geovany's code, in this case pageHeader.

Then adding this to the server function will change the header text to display the selected tab, with switch being used to create a more presentable header format. Note the useShinyJs() in dashboardPage parameters:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
        dashboardHeader(
          title = "demo"
        ),
        dashboardSidebar(),
        dashboardBody(
          tags$head(tags$style(HTML(
            '.myClass {
            font-size: 20px;
            line-height: 50px;
            text-align: left;
            font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
            padding: 0 15px;
            overflow: hidden;
            color: white;
            }
            '))),
          tags$script(HTML('
                           $(document).ready(function() {
                           $("header").find("nav").append(\'<div id="pageHeader" class="myClass"></div>\');
                           })
                           '))
                           ),
        useShinyjs()
)

server <- function(input, output) {
  observeEvent(input$tabs, {
    header <- switch(input$tabs,
                     tab1 = "Tab 1",
                     tab2 = "Tab 2",
                     tab3 = "Tab 3")

    # you can use any other dynamic content you like
    shinyjs::html("pageHeader", header)
  })
}

shinyApp(ui, server)


问:
key is undefined react
when I play this code in my localhost it tell me that "key is not defined"

```<code>import React from 'react';
import PropTypes from 'prop-types'

class LineTable extends React.Component{

supprimerLine = key => {
    const newLines = {...this.state.newLines};
    newLines[key] = null;
    this.setState({newLines})
};
render(){
return(
    <tr>
        <td>{this.props.details.colone1}</td>
        <td>{this.props.details.colone2}</td>
        <td>{this.props.details.colone3}</td>
        <td><button onClick={() => this.props.supprimerLine(key)}>
                                    supprimer</button></td>
    </tr>)};
static propTypes = {
    supprimerLine: PropTypes.func.isRequired};}
export default LineTable
</code>```

I think it is because I did not import the keys but I don't know how I can import it

答:
Key is not defined beacause in your function context does not exists. What do you expect "key" to contain ?

```<code>this.props.supprimerLine(key)
</code>```

should be undefined too because your method resides in your class and not in your props.

Title: key is undefined react

Body:
when I play this code in my localhost it tell me that "key is not defined"

import React from 'react';
import PropTypes from 'prop-types'

class LineTable extends React.Component{

supprimerLine = key => {
    const newLines = {...this.state.newLines};
    newLines[key] = null;
    this.setState({newLines})
};
render(){
return(

        {this.props.details.colone1}
        {this.props.details.colone2}
        {this.props.details.colone3}
        <button onClick={() => this.props.supprimerLine(key)}>
                                    supprimer</button>

)};
static propTypes = {
    supprimerLine: PropTypes.func.isRequired};}
export default LineTable

I think it is because I did not import the keys but I don't know how I can import it

Body:
Key is not defined beacause in your function context does not exists. What do you expect "key" to contain ?

this.props.supprimerLine(key)

should be undefined too because your method resides in your class and not in your props.


问:
AngularJS filter on unknown object key
I have an array, with objects. Each objects contain's the actual value in the key, and the value is always an empty array.

```<code>[ { john : [] }, { foo : [] } ] ...etc
</code>```

I'm using the following HTML to render what I need

```<code><li ng-repeat="(x,y) in tags" class="tag" style="color: white; padding:5px;">
    <span ng-repeat="(c,d) in y" class="label" ng-style="{'background-color': getTagColor(c)}">{{c}}</span>
</li>
</code>```

Which result in displaying a list, just john, foo in this case.

Now I'm wondering, how am I going to filter on this.. ? A regular filter isn't working. I tried using a object key filter like <input ng-model="search.$"> but this does not seem to work.

Thanks in advance!

答:
Answer was simple

```<code>.filter('piemel', function(){
return function(items, value){
    var returnList = [];

    if(items){
        for(x in items){
            var tag = Object.keys(items[x])[0].toLowerCase();

            if(value){
                value = value.toLowerCase();
                if( tag.indexOf(value) != -1){
                    returnList.push(items[x]);
                }
            }
            else{
                returnList.push(items[x]);
            }
        }
    }

    return returnList;
};
})
</code>```

and

```<code>ng-repeat="(x,y) in tags | piemel:searchText"
</code>```

Title: AngularJS filter on unknown object key

Body:
I have an array, with objects. Each objects contain's the actual value in the key, and the value is always an empty array.

[ { john : [] }, { foo : [] } ] ...etc

I'm using the following HTML to render what I need

    {{c}}

Which result in displaying a list, just john, foo in this case.

Now I'm wondering, how am I going to filter on this.. ? A regular filter isn't working. I tried using a object key filter like <input ng-model="search.$"> but this does not seem to work.

Thanks in advance!

Body:
Answer was simple

.filter('piemel', function(){
return function(items, value){
    var returnList = [];

    if(items){
        for(x in items){
            var tag = Object.keys(items[x])[0].toLowerCase();

            if(value){
                value = value.toLowerCase();
                if( tag.indexOf(value) != -1){
                    returnList.push(items[x]);
                }
            }
            else{
                returnList.push(items[x]);
            }
        }
    }

    return returnList;
};
})

and

ng-repeat="(x,y) in tags | piemel:searchText"


问:
loop through implicit array
I've been stuck on this for awhile now. I'm trying to loop through this array so I can perform some calculations but I cannot figure out how to loop through there values. Any suggestions?

I managed to figure out how to get there collection structures but I want to loop through each structure and grab there values as well and thats what I'm stuck on.

Also, I want to refrain from using cfscript if possible as I'm still in the learning stages of learning coldfusion.

Here is my code:

```<code><cfset houseStuff = {
    Bedroom = [
        'Luxury Duvet Set with Alternative Down Comforter',
        'Accent Coverlet & Shams',
        'Two Sets of Luxurious Liens',
        'Mattress Pad',
        'Blanket',
        'Six Bed Pillows',
        'Clock Radio',
        'Twenty Hangers'
    ],
    Bathroom = [
        'Four Bath Towels',
        'Four Hand Towels',
        'Four Face Towels',
        'Bath Rug',
        'Shower Curtain',
        'Stainless Tooth Brush Holder & Soap Dish',
        'Wastebasket',
        'Artwork',
        'Hair Dryer',
        'Toilet Brush & Plunger'
    ],
    Dining = [
        'Dinnerware',
        'Place Mats',
        'Napkins',
        'Flatware',
        'Glassware & Wine Glasses'
    ],
    Kitchen = [
        'Microwave',
        'Cookware',
        'Mixing Bowls',
        'Baking Dish',
        'Colander',
        'Stainless Utensil Holder',
        'Large Fork',
        'Large Spoon',
        'Spatula',
        'Whisk',
        'Measuring Spoon & Cup',
        'Carving & Paring Knives',
        'Four Steak Knives',
        'Cutting Board',
        'Salt & Pepper Set',
        'Wine Opener',
        'Coffee Maker',
        'Toaster',
        'Electric Can Opener',
        'Flatware Tray',
        'Kitchen Wastebasket',
        'Dish Towels',
        'Pot Holders',
        'Pitcher',
        '10" Non-Stick Frying Pan',
        'Cookie Sheet',
        'Stainless Steel Electric Tea Kettle',
        '3 Piece Non-Metal (Spatula, Spoon, Paste Spoon) Combo'
    ],
    Micellaneous = [
        'Iron & Cutting Board',
        'Cordless Dual Phone with Digital Answering Machine',
        'Broom',
        'Dust Pan',
        'Vacuum',
        'Decor',
        'Laundry Basket'
    ],
    StarterKit = [
        'Bath Tissue',
        'Soap',
        'Shampoo & Conditioner',
        'Paper Towels',
        'Sponge',
        'Laundry Soap',
        'Dishwasher Detergent',
        'Liquid Dish Soap',
        'Extra Light Bulbs',
        'Coffee',
        'Sugar',
        'Creamer',
        'Bottled Water',
        'Oatmeal',
        'Breakfast Bars',
        'Peanuts',
        'Chips',
        'Mints',
        'Welcome Information'
    ],
    MasterBedroom = [
        'Queen bed',
        'Headboard',
        'Two Nightstands',
        'Dresser & Mirrior',
        'Two Lamps',
        'Artwork',
        'LCD Television'
    ],
    LivingRoom = [
        'Sofa',
        'Chair',
        'End Table',
        'Coffee Table',
        'Lamp',
        'LCD TV w/stand',
        'DVD Player',
        'Artwork'
    ],
    DiningRoom = [
        'Dining Table',
        'Dining Chairs',
        'Artwork'
    ],
    OfficePackage = [
        'Desk',
        'Chair',
        'Lamp'
    ],
    AdditionalBedrooms = [
        'Queen or Two Twin Beds',
        'Headboard',
        'Nightstand',
        'Chest of Drawers',
        'Lamp',
        'Artwork'
    ]
} />

<cfloop collection="#houseStuff#" item="key">
    <cfdump var="#key#"> <br>
    <!--- <p style="color:##fff;">#key#:</p> <br /> --->
</cfloop>
</code>```

答:
I know you said you'd prefer tags instead of script, but if you are in the learning stages of ColdFusion, I'd still recommend learning how to properly use cfscript. In addition to making your CF a little bit cleaner, it will also make your life a lot easier, especially for things like looping.

Outputting all elements becomes:

```<code><cfscript>
for ( i in houseStuff ) { // loop over the outer Structure
    writeOutput(i & ":<br>") ;
    for ( j in houseStuff[i] ) { // loop over each inner Array key
        writeOutput(j & "<br>") ;
    }
    writeOutput("<br>");
}
</cfscript>
</code>```

https://trycf.com/gist/898988f6969a57aa5dece39c42037cfd/acf?theme=monokai

... which, in this context, does get into the philosophical discussion of whether to write output code in tags or script and goes slightly beyond the scope of this question. But I've always been a proponent of learning best-practices at the same time as the basics. Personally, I do tend to follow the tags-for-output view, but for basic looping, the script version is a bit cleaner to me. I'd learn both.

Also check out: http://www.learncfinaweek.com. There's a section in there on Looping with both methods.

Title: loop through implicit array

Body:
I've been stuck on this for awhile now. I'm trying to loop through this array so I can perform some calculations but I cannot figure out how to loop through there values. Any suggestions?

I managed to figure out how to get there collection structures but I want to loop through each structure and grab there values as well and thats what I'm stuck on.

Also, I want to refrain from using cfscript if possible as I'm still in the learning stages of learning coldfusion.

Here is my code:

<cfset houseStuff = {
    Bedroom = [
        'Luxury Duvet Set with Alternative Down Comforter',
        'Accent Coverlet & Shams',
        'Two Sets of Luxurious Liens',
        'Mattress Pad',
        'Blanket',
        'Six Bed Pillows',
        'Clock Radio',
        'Twenty Hangers'
    ],
    Bathroom = [
        'Four Bath Towels',
        'Four Hand Towels',
        'Four Face Towels',
        'Bath Rug',
        'Shower Curtain',
        'Stainless Tooth Brush Holder & Soap Dish',
        'Wastebasket',
        'Artwork',
        'Hair Dryer',
        'Toilet Brush & Plunger'
    ],
    Dining = [
        'Dinnerware',
        'Place Mats',
        'Napkins',
        'Flatware',
        'Glassware & Wine Glasses'
    ],
    Kitchen = [
        'Microwave',
        'Cookware',
        'Mixing Bowls',
        'Baking Dish',
        'Colander',
        'Stainless Utensil Holder',
        'Large Fork',
        'Large Spoon',
        'Spatula',
        'Whisk',
        'Measuring Spoon & Cup',
        'Carving & Paring Knives',
        'Four Steak Knives',
        'Cutting Board',
        'Salt & Pepper Set',
        'Wine Opener',
        'Coffee Maker',
        'Toaster',
        'Electric Can Opener',
        'Flatware Tray',
        'Kitchen Wastebasket',
        'Dish Towels',
        'Pot Holders',
        'Pitcher',
        '10" Non-Stick Frying Pan',
        'Cookie Sheet',
        'Stainless Steel Electric Tea Kettle',
        '3 Piece Non-Metal (Spatula, Spoon, Paste Spoon) Combo'
    ],
    Micellaneous = [
        'Iron & Cutting Board',
        'Cordless Dual Phone with Digital Answering Machine',
        'Broom',
        'Dust Pan',
        'Vacuum',
        'Decor',
        'Laundry Basket'
    ],
    StarterKit = [
        'Bath Tissue',
        'Soap',
        'Shampoo & Conditioner',
        'Paper Towels',
        'Sponge',
        'Laundry Soap',
        'Dishwasher Detergent',
        'Liquid Dish Soap',
        'Extra Light Bulbs',
        'Coffee',
        'Sugar',
        'Creamer',
        'Bottled Water',
        'Oatmeal',
        'Breakfast Bars',
        'Peanuts',
        'Chips',
        'Mints',
        'Welcome Information'
    ],
    MasterBedroom = [
        'Queen bed',
        'Headboard',
        'Two Nightstands',
        'Dresser & Mirrior',
        'Two Lamps',
        'Artwork',
        'LCD Television'
    ],
    LivingRoom = [
        'Sofa',
        'Chair',
        'End Table',
        'Coffee Table',
        'Lamp',
        'LCD TV w/stand',
        'DVD Player',
        'Artwork'
    ],
    DiningRoom = [
        'Dining Table',
        'Dining Chairs',
        'Artwork'
    ],
    OfficePackage = [
        'Desk',
        'Chair',
        'Lamp'
    ],
    AdditionalBedrooms = [
        'Queen or Two Twin Beds',
        'Headboard',
        'Nightstand',
        'Chest of Drawers',
        'Lamp',
        'Artwork'
    ]
} />

<cfloop collection="#houseStuff#" item="key">
    <cfdump var="#key#">

</cfloop>

Body:
I know you said you'd prefer tags instead of script, but if you are in the learning stages of ColdFusion, I'd still recommend learning how to properly use cfscript. In addition to making your CF a little bit cleaner, it will also make your life a lot easier, especially for things like looping.

Outputting all elements becomes:

<cfscript>
for ( i in houseStuff ) { // loop over the outer Structure
    writeOutput(i & ":<br>") ;
    for ( j in houseStuff[i] ) { // loop over each inner Array key
        writeOutput(j & "<br>") ;
    }
    writeOutput("<br>");
}
</cfscript>

https://trycf.com/gist/898988f6969a57aa5dece39c42037cfd/acf?theme=monokai

... which, in this context, does get into the philosophical discussion of whether to write output code in tags or script and goes slightly beyond the scope of this question. But I've always been a proponent of learning best-practices at the same time as the basics. Personally, I do tend to follow the tags-for-output view, but for basic looping, the script version is a bit cleaner to me. I'd learn both.

Also check out: http://www.learncfinaweek.com. There's a section in there on Looping with both methods.


问:
Join two tables with composite key in hibernate
I'm new to hibernate I couldn’t find a solution for this problem.
I have two tables as follows.

```<code>User
----

Id
fistName
lastName

subscribed
----------

subscribedBy
subscribedTo
</code>```

A user can subscribe to another user. Therefore both subscribedBy and subscribedTo are user ids and both columns together create a composite key.

For an example user1 has been subscribed to user2 and user3. I want to get the details about user2 and user3 using hibernate entity. But I don't need to get the details about subscribedBy user other than id.

Something like this,

```<code>public class subscribed {

    private long subscribedBy;
    private List< User> subscribedToUsers;
}
</code>```

答:
You're looking for Hibernate's @ManyToMany. No need to create the join table; Hibernate will do that for you:

```<code>class User {
    @Id
    Long Id
    String fistName
    String lastName

    @ManyToMany
    Collection<User> subscriptions
}
</code>```

Body:
I'm new to hibernate I couldn’t find a solution for this problem.
I have two tables as follows.

User
----

Id
fistName
lastName

subscribed
----------

subscribedBy
subscribedTo

A user can subscribe to another user. Therefore both subscribedBy and subscribedTo are user ids and both columns together create a composite key.

For an example user1 has been subscribed to user2 and user3. I want to get the details about user2 and user3 using hibernate entity. But I don't need to get the details about subscribedBy user other than id.

Something like this,

public class subscribed {

    private long subscribedBy;
    private List< User> subscribedToUsers;
}

Body:
You're looking for Hibernate's @ManyToMany. No need to create the join table; Hibernate will do that for you:

class User {
    @Id
    Long Id
    String fistName
    String lastName

    @ManyToMany
    Collection<User> subscriptions
}


问:
asp.net Validation: ZIP from Germany, Switzerland and Austria
I have a TextBox for the ZIP and a ComboBox for the country (selectable: germany, switzerland and austria).

I am not much familiar with RegEx, I get it to build a simple one for ZIP of germany, but how to build one for allowed ZIPs of germany, switzerland and austria?

答:
You should mention what rules the ZIP codes follow. A quick peek tells me they have 4 (Switzerland, Austria) or 5 (Germany) numbers.

```<code>/^\d{4,5}$/
</code>```

would match that. If you want a more specific answer, then be more specific in your post.

Body:
You should mention what rules the ZIP codes follow. A quick peek tells me they have 4 (Switzerland, Austria) or 5 (Germany) numbers.

/^\d{4,5}$/

would match that. If you want a more specific answer, then be more specific in your post.


问:
After installing anaconda - command not found: jupyter
I have installed anaconda on my MAC laptop, and tried to run jupyter notebook to install it, but I get error jupyter command not found.</p>

答:
Add $HOME/anaconda3/bin to your $PATH and jupyter-notebook should work. There are a ton of other binaries you can lookup in that folder as well.

```<code>export PATH=$HOME/anaconda3/bin:$PATH
</code>```

then

```<code>jupyter-notebook
</code>```

Body:
Add $HOME/anaconda3/bin to your $PATH and jupyter-notebook should work. There are a ton of other binaries you can lookup in that folder as well.

export PATH=$HOME/anaconda3/bin:$PATH

then

jupyter-notebook


问:
CKEditor 4: how to force the "framed" mode
Automatically CKEditor uses the "inline" mode, while I would like to use the "framed" mode.

This happens in my case, even if reading the documentation does not seem normal, I'm probably doing something wrong.

I have a simple textarea, to which I also tried to add the contenteditable attribute, without any success.

```<code><textarea name="text" class="form-control wysiwyg editor" id="text" rows="10" contenteditable="false"></textarea>
</code>```

This is instead the code with which I initialize the editor:

```<code>$(function () {
    $('.editor.wysiwyg').each(function () {
       CKEDITOR.disableAutoInline = true;
        CKEDITOR.replace(this.id, {
            disableNativeSpellChecker: false,
            fontSize_sizes: '10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;30/30px;',
            height: 375,
            image2_alignClasses: [ 'float-left', 'text-center', 'float-right' ],
            insertpre_class: false,
            removeButtons: 'Font',
            removeDialogTabs: false,
            tabSpaces: 4,
            toolbarCanCollapse: true,
            toolbarGroups: [
                { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
                { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
                { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
                { name: 'links' },
                { name: 'insert' },
                { name: 'forms' },
                { name: 'tools' },
                { name: 'others' },
                '/',
                { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
                { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
                { name: 'styles' },
                { name: 'colors' },
                { name: 'about' }
            ],
        });
    });
});
</code>```

I have read this and this page of the documentation, but I have not found anything useful.

I'm using the jQuery adapter.

How can I do? Thank you.

答:
Solved.

The problem was caused by the divarea plugin. Instead, we need to use the  IFrame Editing Areaplugin.

In fact, in the plugin page it is explained that:

This is the core functionality of the classic, iframe-based editor which can only be disabled if it is backfilled by an alternative plugin (such as Div Editing Area) or if only inline editor is used.

Too bad that this is not explained in the documentation (how to report it to who takes care of the documentation?).

So I make sure I have the right plugin, then I used the removePlugins config option to disable the divarea plugin.

Body:
Automatically CKEditor uses the "inline" mode, while I would like to use the "framed" mode.

This happens in my case, even if reading the documentation does not seem normal, I'm probably doing something wrong.

I have a simple textarea, to which I also tried to add the contenteditable attribute, without any success.

<textarea name="text" class="form-control wysiwyg editor" id="text" rows="10" contenteditable="false"></textarea>

This is instead the code with which I initialize the editor:

$(function () {
    $('.editor.wysiwyg').each(function () {
       CKEDITOR.disableAutoInline = true;
        CKEDITOR.replace(this.id, {
            disableNativeSpellChecker: false,
            fontSize_sizes: '10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;30/30px;',
            height: 375,
            image2_alignClasses: [ 'float-left', 'text-center', 'float-right' ],
            insertpre_class: false,
            removeButtons: 'Font',
            removeDialogTabs: false,
            tabSpaces: 4,
            toolbarCanCollapse: true,
            toolbarGroups: [
                { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
                { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
                { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
                { name: 'links' },
                { name: 'insert' },
                { name: 'forms' },
                { name: 'tools' },
                { name: 'others' },
                '/',
                { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
                { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
                { name: 'styles' },
                { name: 'colors' },
                { name: 'about' }
            ],
        });
    });
});

I have read this and this page of the documentation, but I have not found anything useful.

I'm using the jQuery adapter.

How can I do? Thank you.


问:
Jquery and Google Tag Manager
I am having some problems implementing Google Tag Manager on my website. I have a Google code, and when I try it on my site, it makes a lot of javascript conflicts.

So I tried to put the code on a seperate file, in order to do it Step by Step and observe the behavior of the different scripts.

So here my very simple HTML page:

```<code><!DOCTYPE html>
<html>
<head>
    <title>Titre</title>
</head>
<body>
    <!-- Google Tag Manager -->
    <noscript>
    <iframe src="http://www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe>
    </noscript>
    <script type="text/javascript">
        dataLayer = [{'uid':'12'}];
        (function(w,d,s,l,i){
            w[l]=w[l]||[];
            w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
            var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
            j.async=true;
            j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;
            f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','GTM-XXXXXX');
    </script>
    <!-- End Google Tag Manager -->
    hello
</body>
</html>
</code>```

And this very page, returns an error in the JS console:

```<code>Uncaught ReferenceError: jQuery is not defined
</code>```

Well, this is unexpected, what does jQuery has to do here? I didn't even declare it on my body tag, is Google requiring jQuery?

So that was weird, and the second thing, when I look on my generated HTML page, after loading on a browser:

```<code><body>
... Long stuff here
<script type="text/javascript" id="" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
... some other stuff here
</body>
</code>```

What kind of sorcery is this? Why does Google add a jquery thing at the bottom of my page, and why does my console shows me a jQuery error?

Thanks a lot for any kind of information, I am totally lost...
And have a nice day!

答:
Like it has been said before, GTM might load before the page's jQuery loads. That means that if you use jQuery in the script injected via GTM, it might generate a "Uncaught ReferenceError: jQuery is not defined", depending on the browser resource loading strategy.

That said, you must guarantee jQuery is loaded before the GTM script. You can do this by either:

controlling the order of loading of scripts

employing a hack such as using a setInterval loop until jQUery is available:

var func = function() {
    if (jQuery) {
        clearInterval(timer);
        // do your stuff
    }
}
var timer = setInterval(func, 1000);
```

Title: Jquery and Google Tag Manager

Body:
I am having some problems implementing Google Tag Manager on my website. I have a Google code, and when I try it on my site, it makes a lot of javascript conflicts.

So I tried to put the code on a seperate file, in order to do it Step by Step and observe the behavior of the different scripts.

So here my very simple HTML page:

<!DOCTYPE html>

    <title>Titre</title>

    hello

And this very page, returns an error in the JS console:

Uncaught ReferenceError: jQuery is not defined

Well, this is unexpected, what does jQuery has to do here? I didn't even declare it on my body tag, is Google requiring jQuery?

So that was weird, and the second thing, when I look on my generated HTML page, after loading on a browser:

... Long stuff here

... some other stuff here

What kind of sorcery is this? Why does Google add a jquery thing at the bottom of my page, and why does my console shows me a jQuery error?

Thanks a lot for any kind of information, I am totally lost...
And have a nice day!


问:
how to set date value in frontend with ngoninit in angular 5
i have an <input type="date"> which i want to be filled when the user enters the route. By visiting the site the input field should already be the actual date.
So i think ngOnInit() should be what i need. But what do i have to do to have the actual date filled in as a value to the input field, when the user enters the route?

I already tried to achive this by searching the web but only found some old solutions for angularjs although i'm using angular 5 which is not compareable with angularjs. The postings i found all pointed to the scope which is no longer existent.

The Documentation for ngOnInit also does not help me :/

HTML

```<code><div class="form-group">
    <label>Eingangsdatum</label>
    <input type="date" [(ngModel)]="dateArrival" id="dateArrivalPicker" value="" name="dateArrival" class="form-control">
</div>
</code>```

Compontent

```<code>@Component({
  selector: 'app-terminals-create',
  templateUrl: './terminals-create.component.html',
  styleUrls: ['./terminals-create.component.css']
})
export class TerminalsCreateComponent implements OnInit {

  type: String;
  serial: String;
  layout: String;
  dateArrival: Date;
  activated: Boolean;
  setup: String;
  firmware: String;
  installedAt: String;
  createdBy: String;
  createdDate: Date;
  lastModified: Date;
  lastModifiedBy: String;
  notes: String;
  macAddress: String;

  constructor(
    private validateService: ValidateService,
    private flashMessage: FlashMessagesService,
    private authService: AuthService,
    private router: Router
  ) { }

  ngOnInit() {}

}
</code>```

If i do like briosheje wrote in his comments it works, his answer doesn't :/. And there is one more thing... by using his comment i get two big errors inside my console:

```<code>Error: If ngModel is used within a form tag, either the name attribute must be set or the form
      control must be defined as 'standalone' in ngModelOptions.

      Example 1: <input [(ngModel)]="person.firstName" name="first">
      Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">
</code>```

If i now give a name to my <input type="date" [ngModel]="todaysDate | date:'dd-MM-yyyy'" (ngModelChange)="todaysDate = $event" [value]="todaysDate | date:'yyyy-MM-dd'">
the function of filling this field with the acutal date is gone and only TT.MM.YYYY stands there. What can i do?

答:
You can create a variable in your component.ts like:

```<code>todaysDate: Date = new Date();
</code>```

Then in your template:

```<code><input type="text" [value]="todaysDate">
</code>```

Body:
i have an <input type="date"> which i want to be filled when the user enters the route. By visiting the site the input field should already be the actual date.
So i think ngOnInit() should be what i need. But what do i have to do to have the actual date filled in as a value to the input field, when the user enters the route?

I already tried to achive this by searching the web but only found some old solutions for angularjs although i'm using angular 5 which is not compareable with angularjs. The postings i found all pointed to the scope which is no longer existent.

The Documentation for ngOnInit also does not help me :/

HTML

    Eingangsdatum
    <input type="date" [(ngModel)]="dateArrival" id="dateArrivalPicker" value="" name="dateArrival" class="form-control">

Compontent

@Component({
  selector: 'app-terminals-create',
  templateUrl: './terminals-create.component.html',
  styleUrls: ['./terminals-create.component.css']
})
export class TerminalsCreateComponent implements OnInit {

  type: String;
  serial: String;
  layout: String;
  dateArrival: Date;
  activated: Boolean;
  setup: String;
  firmware: String;
  installedAt: String;
  createdBy: String;
  createdDate: Date;
  lastModified: Date;
  lastModifiedBy: String;
  notes: String;
  macAddress: String;

  constructor(
    private validateService: ValidateService,
    private flashMessage: FlashMessagesService,
    private authService: AuthService,
    private router: Router
  ) { }

  ngOnInit() {}

}

If i do like briosheje wrote in his comments it works, his answer doesn't :/. And there is one more thing... by using his comment i get two big errors inside my console:

Error: If ngModel is used within a form tag, either the name attribute must be set or the form
      control must be defined as 'standalone' in ngModelOptions.

      Example 1: <input [(ngModel)]="person.firstName" name="first">
      Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">

If i now give a name to my <input type="date" [ngModel]="todaysDate | date:'dd-MM-yyyy'" (ngModelChange)="todaysDate = $event" [value]="todaysDate | date:'yyyy-MM-dd'">
the function of filling this field with the acutal date is gone and only TT.MM.YYYY stands there. What can i do?

Body:
You can create a variable in your component.ts like:

todaysDate: Date = new Date();

Then in your template:

<input type="text" [value]="todaysDate">


问:
For loop issue writing multiple lines to database
The for loop below has an issue when writing to the database.  Only the first record is coming through, i believe it's because report_name_sc = reportlist is writing the query set to the database.   How can I get it to write a single line for each report_id?

```<code>checkedlist = request.GET.getlist('report_id')
reportlist = QvReportList.objects.filter(report_id__in= checkedlist, active = 1).values_list('report_name_sc',flat = True)

for i in checkedlist:
    requestsave = QVFormAccessRequest(ntname_id = owner.formattedusername, first_name = owner.first_name, last_name = owner.last_name, coid = owner.coid, facility = owner.facility, title = owner.title
                                  ,report_id = i, report_name_sc = reportlist, accesslevel_id = '7', phi = '1', access_beg_date = '2017-01-01', access_end_date = '2017-01-31')
    requestsave.save()
</code>```

Models.py added as requested, checked list is a collection of check boxes getting report_id:

```<code>   from __future__ import unicode_literals
    from django.utils import timezone
    from django.contrib.auth.models import (AbstractBaseUser,PermissionsMixin)
    from django.db import models
    from django.conf import settings
    from django.forms import ModelForm

    class User(AbstractBaseUser, PermissionsMixin):

        email = models.EmailField(unique=True)
        username = models.CharField(max_length=7, unique=True)
        formattedusername = models.CharField(max_length=11, unique=True, primary_key = True)
        first_name = models.CharField(max_length=40)
        last_name = models.CharField(max_length=140)
        date_joined = models.DateTimeField(default=timezone.now)
        is_active = models.BooleanField(default=True)
        is_staff = models.BooleanField(default=False)
        is_cfo = models.BooleanField(default=False)
        facility = models.CharField(max_length=140)
        officename = models.CharField(max_length=100)
        jobdescription = models.CharField(max_length=140)
        positioncode = models.CharField(max_length = 100)
        positiondescription = models.CharField(max_length=140)
        coid = models.CharField(max_length=5)
        streetaddress = models.CharField(max_length=140)
        title = models.CharField(max_length=100)

        USERNAME_FIELD = 'username'

        class Meta:
            app_label = 'accounts'
            db_table = "user"

        def save(self, *args, **kwargs):
            self.formattedusername = '{domain}\{username}'.format(
                domain='HCA', username=self.username)
            super(User, self).save(*args, **kwargs);

        def get_short_name(self):
            return self.username

    #    REQUIRED_FIELDS = "username"

        def __str__(self):
            return '%s - %s %s' % (self.username, self.first_name, self.last_name)

    class FacilityDimension(models.Model):
        unit_num = models.CharField(db_column='Unit_Num', max_length=5, blank=True, null=True)  # Field name made lowercase.
        company_code = models.CharField(db_column='Company_Code', max_length=1, blank=True, null=True)  # Field name made lowercase.
        coid = models.CharField(db_column='Coid',primary_key=True, serialize=False, max_length=5)  # Field name made lowercase.
        coid_name = models.CharField(db_column='COID_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        c_level = models.CharField(db_column='C_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        company_name = models.CharField(db_column='Company_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        s_level = models.CharField(db_column='S_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        sector_name = models.CharField(db_column='Sector_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        b_level = models.CharField(db_column='B_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        group_name = models.CharField(db_column='Group_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        r_level = models.CharField(db_column='R_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        division_name = models.CharField(db_column='Division_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        d_level = models.CharField(db_column='D_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        market_name = models.CharField(db_column='Market_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        f_level = models.CharField(db_column='F_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        cons_facility_name = models.CharField(db_column='Cons_Facility_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        lob_code = models.CharField(db_column='LOB_Code', max_length=3, blank=True, null=True)  # Field name made lowercase.
        lob_name = models.CharField(db_column='LOB_Name', max_length=20, blank=True, null=True)  # Field name made lowercase.
        sub_lob_code = models.CharField(db_column='Sub_LOB_Code', max_length=3, blank=True, null=True)  # Field name made lowercase.
        sub_lob_name = models.CharField(db_column='Sub_LOB_Name', max_length=20, blank=True, null=True)  # Field name made lowercase.
        state_code = models.CharField(db_column='State_Code', max_length=2, blank=True, null=True)  # Field name made lowercase.
        pas_id_current = models.CharField(db_column='PAS_ID_Current', max_length=8, blank=True, null=True)  # Field name made lowercase.
        pas_current_name = models.CharField(db_column='PAS_Current_Name', max_length=40, blank=True, null=True)  # Field name made lowercase.
        pas_id_future = models.CharField(db_column='PAS_ID_Future', max_length=8, blank=True, null=True)  # Field name made lowercase.
        pas_future_name = models.CharField(db_column='PAS_Future_Name', max_length=40, blank=True, null=True)  # Field name made lowercase.
        summary_7_member_ind = models.CharField(db_column='Summary_7_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_8_member_ind = models.CharField(db_column='Summary_8_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_phys_svc_member_ind = models.CharField(db_column='Summary_Phys_Svc_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_asd_member_ind = models.CharField(db_column='Summary_ASD_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_imaging_member_ind = models.CharField(db_column='Summary_Imaging_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_oncology_member_ind = models.CharField(db_column='Summary_Oncology_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_cath_lab_member_ind = models.CharField(db_column='Summary_Cath_Lab_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_intl_member_ind = models.CharField(db_column='Summary_Intl_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_other_member_ind = models.CharField(db_column='Summary_Other_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        pas_coid = models.CharField(db_column='PAS_COID', max_length=5, blank=True, null=True)  # Field name made lowercase.
        pas_status = models.CharField(db_column='PAS_Status', max_length=1, blank=True, null=True)  # Field name made lowercase.
        company_code_operations = models.CharField(db_column='Company_Code_Operations', max_length=3, blank=True, null=True)  # Field name made lowercase.
        osg_pas_ind = models.CharField(db_column='OSG_PAS_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        abs_facility_member_ind = models.CharField(db_column='ABS_Facility_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        abl_facility_member_ind = models.CharField(db_column='ABL_Facility_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        intl_pmis_member_ind = models.CharField(db_column='INTL_PMIS_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        hsc_member_ind = models.CharField(db_column='HSC_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        loaddate = models.DateTimeField(db_column='LoadDate', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'Facility_Dimension'

    class QvDatareducecfo(models.Model):
        cfo_fname = models.CharField(db_column='CFO_FName', max_length=100, blank=True, null=True)  # Field name made lowercase.
        cfo_lname = models.CharField(db_column='CFO_LName', max_length=100, blank=True, null=True)  # Field name made lowercase.
        cfo_ntname = models.OneToOneField(settings.AUTH_USER_MODEL,db_column='CFO_NTName',max_length=11, primary_key=True)  # Field name made lowercase.
        cfo_type = models.IntegerField(db_column='CFO_Type', blank=True, null=True)  # Field name made lowercase.
        org_level_id = models.IntegerField(db_column='Org_Level_ID', blank=True, null=True)  # Field name made lowercase.
        org_level = models.CharField(db_column='Org_Level', max_length=255, blank=True, null=True)  # Field name made lowercase.
        unit_no = models.CharField(db_column='Unit_No', max_length=10, blank=True, null=True)  # Field name made lowercase.
        dr_code = models.CharField(db_column='DR_Code', max_length=255, blank=True, null=True)  # Field name made lowercase.
        dr_name = models.CharField(db_column='DR_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        cfo_dr_code = models.CharField(db_column='CFO_DR_Code', max_length=255, blank=True, null=True)  # Field name made lowercase.
        cfo_dr_name = models.CharField(db_column='CFO_DR_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        b_level = models.CharField(db_column='B_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        group_name = models.CharField(db_column='Group_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True)  # Field name made lowercase.
        beg_date = models.DateTimeField(db_column='Beg_Date', blank=True, null=True)  # Field name made lowercase.
        end_date = models.DateTimeField(db_column='End_Date', blank=True, null=True)  # Field name made lowercase.
        active = models.IntegerField(db_column='Active', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'QV_DataReduceCFO'

        def __str__(self):
            return str(self.cfo_ntname)

    class QvReportList(models.Model):
        qv_dept_id = models.CharField(db_column='QV_Dept_ID', max_length=100)  # Field name made lowercase.
        report_id = models.CharField(db_column='Report_ID',primary_key=True, max_length=100, serialize=False)  # Field name made lowercase.
        report_name = models.CharField(db_column='Report_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        report_name_sc = models.CharField(db_column='Report_Name_SC', max_length=255, blank=True, null=True)  # Field name made lowercase.
        qv_filename = models.CharField(db_column='QV_FileName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        report_access = models.CharField(db_column='Report_Access', max_length=20, blank=True, null=True)  # Field name made lowercase.
        report_group_id = models.IntegerField(db_column='Report_Group_ID', blank=True, null=True)  # Field name made lowercase.
        report_sub_group_id = models.IntegerField(db_column='Report_Sub_Group_ID', blank=True, null=True)  # Field name made lowercase.
        load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True)  # Field name made lowercase.
        approver_fname = models.CharField(db_column='Approver_FName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        approver_lname = models.CharField(db_column='Approver_LName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        approver_ntname = models.CharField(db_column='Approver_NTName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        beg_date = models.DateTimeField(db_column='Beg_Date', blank=True, null=True)  # Field name made lowercase.
        end_date = models.DateTimeField(db_column='End_Date', blank=True, null=True)  # Field name made lowercase.
        active = models.IntegerField(db_column='Active', blank=True, null=True)  # Field name made lowercase.
        approval_id = models.IntegerField(db_column='Approval_ID', blank=True, null=True)  # Field name made lowercase.
        role_based_id = models.IntegerField(db_column='Role_Based_ID', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'QV_Report_List'

    class QVReportAccess(models.Model):
        user_status = models.CharField(db_column='User_Status', max_length = 20)  # Field name made lowercase.
        ntname = models.OneToOneField(settings.AUTH_USER_MODEL,db_column='NTName', max_length=11,primary_key=True, serialize=False)  # Field name made lowercase.
        report_name = models.CharField(db_column='Report_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        report_name_sc = models.CharField(db_column='Report_Name_SC', max_length=30, blank=True, null=True)  # Field name made lowercase.
        datareduce_report_code = models.IntegerField(db_column='DataReduce_Report_Code', blank=True, null=True)  # Field name made lowercase.
        role_based_id = models.IntegerField(db_column='Role_Based_ID', blank=True, null=True)  # Field name made lowercase.
        report_id = models.OneToOneField(QvReportList,db_column='Report_ID', max_length=100, blank=True, null=True)  # Field name made lowercase.
        report_group_id = models.IntegerField(db_column='Report_Group_ID', blank=True, null=True)  # Field name made lowercase.
        report_access = models.CharField(db_column='Report_Access', max_length=50, blank=True, null=True)  # Field name made lowercase.
        sr_datareduce_summary_code = models.CharField(db_column='SR_DataReduce_Summary_Code', max_length=10, blank=True, null=True)  # Field name made lowercase.
        sr_datareduce_patient_code = models.CharField(db_column='SR_DataReduce_Patient_Code', max_length=10, blank=True, null=True)  # Field name made lowercase.
        userid = models.IntegerField(db_column='UserID', blank=True, null=True)  # Field name made lowercase.
        user_group_id = models.IntegerField(db_column='User_Group_ID', blank=True, null=True)
        access_level_id = models.IntegerField(db_column='Access_Level_ID', blank=True, null=True)
        active = models.IntegerField(db_column='Active', blank=True, null=True)
        qv_statusid = models.IntegerField(db_column='QV_StatusID', blank=True, null=True)
        employee_status_id = models.IntegerField(db_column='Employee_Status_ID', blank = True, null = True)
        new_user = models.IntegerField(db_column='New_User', blank = True, null = True)
        new_access = models.IntegerField(db_column='New_Access', blank = True, null = True)
        new_report = models.IntegerField(db_column='New_Report', blank = True, null = True)
        changed_row = models.IntegerField(db_column='Changed_Row',blank = True, null = True)
        last_change_date = models.DateTimeField(db_column='Last_Change_Date', blank=True, null=True)  # Field name made lowercase.
        access_beg_date = models.DateTimeField(db_column='Access_Beg_Date', blank=True, null=True)  # Field name made lowercase.
        access_end_date = models.DateTimeField(db_column='Access_End_Date', blank=True, null=True)  # Field name made lowercase.
        report_beg_date = models.DateTimeField(db_column='Report_Beg_Date', blank=True, null=True)  # Field name made lowercase.
        report_end_date = models.DateTimeField(db_column='Report_End_Date', blank=True, null=True)  # Field name made lowercase.
        qv_startdate = models.DateTimeField(db_column='QV_StartDate', blank=True, null=True)  # Field name made lowercase.
        load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'QV_ReportAccess'

class QVFormAccessRequest(models.Model):
    ntname = models.CharField(max_length=11)
    first_name = models.CharField(max_length=40)
    last_name = models.CharField(max_length=140)
    coid = models.CharField(max_length=5)
    facility = models.CharField(max_length=140)
    title = models.CharField(max_length=100)
    report_id = models.CharField(max_length=100)
    report_name_sc = models.CharField(max_length=100, blank=True, null=True)
    accesslevel_id = models.CharField(max_length=100)
    phi = models.BooleanField(default=False)
    access_beg_date = models.DateTimeField(blank=True, null=True)  # Field name made lowercase.
    access_end_date = models.DateTimeField(blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = True
        db_table = 'QV_FormAccessRequest'

    class DjangoMigrations(models.Model):
        app = models.CharField(max_length=255)
        name = models.CharField(max_length=255)
        applied = models.DateTimeField()

        class Meta:
            managed = False
            db_table = 'django_migrations'

    class Sysdiagrams(models.Model):
        name = models.CharField(max_length=128)
        principal_id = models.IntegerField()
        diagram_id = models.AutoField(primary_key=True)
        version = models.IntegerField(blank=True, null=True)
        definition = models.BinaryField(blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'sysdiagrams'
            unique_together = (('principal_id', 'name'),)
</code>```

答:
Your QVFormAccessRequest model specifies ntname to be a primary key. So, there cannot be to model instances with the same primary key.

In your loop, you are iterating over checkedlist, but you always set the same ntname_id, so you are overwriting the previous object.

I suspect that you need to change your model to support what you want to achieve. Maybe, it is enough to remove the primary key constraint from ntname and let Django create a surrogate key (artificial key) for you.

Body:
The for loop below has an issue when writing to the database.  Only the first record is coming through, i believe it's because report_name_sc = reportlist is writing the query set to the database.   How can I get it to write a single line for each report_id?

checkedlist = request.GET.getlist('report_id')
reportlist = QvReportList.objects.filter(report_id__in= checkedlist, active = 1).values_list('report_name_sc',flat = True)

for i in checkedlist:
    requestsave = QVFormAccessRequest(ntname_id = owner.formattedusername, first_name = owner.first_name, last_name = owner.last_name, coid = owner.coid, facility = owner.facility, title = owner.title
                                  ,report_id = i, report_name_sc = reportlist, accesslevel_id = '7', phi = '1', access_beg_date = '2017-01-01', access_end_date = '2017-01-31')
    requestsave.save()

Models.py added as requested, checked list is a collection of check boxes getting report_id:

   from __future__ import unicode_literals
    from django.utils import timezone
    from django.contrib.auth.models import (AbstractBaseUser,PermissionsMixin)
    from django.db import models
    from django.conf import settings
    from django.forms import ModelForm

    class User(AbstractBaseUser, PermissionsMixin):

        email = models.EmailField(unique=True)
        username = models.CharField(max_length=7, unique=True)
        formattedusername = models.CharField(max_length=11, unique=True, primary_key = True)
        first_name = models.CharField(max_length=40)
        last_name = models.CharField(max_length=140)
        date_joined = models.DateTimeField(default=timezone.now)
        is_active = models.BooleanField(default=True)
        is_staff = models.BooleanField(default=False)
        is_cfo = models.BooleanField(default=False)
        facility = models.CharField(max_length=140)
        officename = models.CharField(max_length=100)
        jobdescription = models.CharField(max_length=140)
        positioncode = models.CharField(max_length = 100)
        positiondescription = models.CharField(max_length=140)
        coid = models.CharField(max_length=5)
        streetaddress = models.CharField(max_length=140)
        title = models.CharField(max_length=100)

        USERNAME_FIELD = 'username'

        class Meta:
            app_label = 'accounts'
            db_table = "user"

        def save(self, *args, **kwargs):
            self.formattedusername = '{domain}\{username}'.format(
                domain='HCA', username=self.username)
            super(User, self).save(*args, **kwargs);

        def get_short_name(self):
            return self.username

    #    REQUIRED_FIELDS = "username"

        def __str__(self):
            return '%s - %s %s' % (self.username, self.first_name, self.last_name)

    class FacilityDimension(models.Model):
        unit_num = models.CharField(db_column='Unit_Num', max_length=5, blank=True, null=True)  # Field name made lowercase.
        company_code = models.CharField(db_column='Company_Code', max_length=1, blank=True, null=True)  # Field name made lowercase.
        coid = models.CharField(db_column='Coid',primary_key=True, serialize=False, max_length=5)  # Field name made lowercase.
        coid_name = models.CharField(db_column='COID_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        c_level = models.CharField(db_column='C_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        company_name = models.CharField(db_column='Company_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        s_level = models.CharField(db_column='S_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        sector_name = models.CharField(db_column='Sector_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        b_level = models.CharField(db_column='B_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        group_name = models.CharField(db_column='Group_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        r_level = models.CharField(db_column='R_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        division_name = models.CharField(db_column='Division_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        d_level = models.CharField(db_column='D_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        market_name = models.CharField(db_column='Market_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        f_level = models.CharField(db_column='F_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        cons_facility_name = models.CharField(db_column='Cons_Facility_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        lob_code = models.CharField(db_column='LOB_Code', max_length=3, blank=True, null=True)  # Field name made lowercase.
        lob_name = models.CharField(db_column='LOB_Name', max_length=20, blank=True, null=True)  # Field name made lowercase.
        sub_lob_code = models.CharField(db_column='Sub_LOB_Code', max_length=3, blank=True, null=True)  # Field name made lowercase.
        sub_lob_name = models.CharField(db_column='Sub_LOB_Name', max_length=20, blank=True, null=True)  # Field name made lowercase.
        state_code = models.CharField(db_column='State_Code', max_length=2, blank=True, null=True)  # Field name made lowercase.
        pas_id_current = models.CharField(db_column='PAS_ID_Current', max_length=8, blank=True, null=True)  # Field name made lowercase.
        pas_current_name = models.CharField(db_column='PAS_Current_Name', max_length=40, blank=True, null=True)  # Field name made lowercase.
        pas_id_future = models.CharField(db_column='PAS_ID_Future', max_length=8, blank=True, null=True)  # Field name made lowercase.
        pas_future_name = models.CharField(db_column='PAS_Future_Name', max_length=40, blank=True, null=True)  # Field name made lowercase.
        summary_7_member_ind = models.CharField(db_column='Summary_7_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_8_member_ind = models.CharField(db_column='Summary_8_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_phys_svc_member_ind = models.CharField(db_column='Summary_Phys_Svc_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_asd_member_ind = models.CharField(db_column='Summary_ASD_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_imaging_member_ind = models.CharField(db_column='Summary_Imaging_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_oncology_member_ind = models.CharField(db_column='Summary_Oncology_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_cath_lab_member_ind = models.CharField(db_column='Summary_Cath_Lab_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_intl_member_ind = models.CharField(db_column='Summary_Intl_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        summary_other_member_ind = models.CharField(db_column='Summary_Other_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        pas_coid = models.CharField(db_column='PAS_COID', max_length=5, blank=True, null=True)  # Field name made lowercase.
        pas_status = models.CharField(db_column='PAS_Status', max_length=1, blank=True, null=True)  # Field name made lowercase.
        company_code_operations = models.CharField(db_column='Company_Code_Operations', max_length=3, blank=True, null=True)  # Field name made lowercase.
        osg_pas_ind = models.CharField(db_column='OSG_PAS_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        abs_facility_member_ind = models.CharField(db_column='ABS_Facility_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        abl_facility_member_ind = models.CharField(db_column='ABL_Facility_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        intl_pmis_member_ind = models.CharField(db_column='INTL_PMIS_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        hsc_member_ind = models.CharField(db_column='HSC_Member_Ind', max_length=1, blank=True, null=True)  # Field name made lowercase.
        loaddate = models.DateTimeField(db_column='LoadDate', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'Facility_Dimension'

    class QvDatareducecfo(models.Model):
        cfo_fname = models.CharField(db_column='CFO_FName', max_length=100, blank=True, null=True)  # Field name made lowercase.
        cfo_lname = models.CharField(db_column='CFO_LName', max_length=100, blank=True, null=True)  # Field name made lowercase.
        cfo_ntname = models.OneToOneField(settings.AUTH_USER_MODEL,db_column='CFO_NTName',max_length=11, primary_key=True)  # Field name made lowercase.
        cfo_type = models.IntegerField(db_column='CFO_Type', blank=True, null=True)  # Field name made lowercase.
        org_level_id = models.IntegerField(db_column='Org_Level_ID', blank=True, null=True)  # Field name made lowercase.
        org_level = models.CharField(db_column='Org_Level', max_length=255, blank=True, null=True)  # Field name made lowercase.
        unit_no = models.CharField(db_column='Unit_No', max_length=10, blank=True, null=True)  # Field name made lowercase.
        dr_code = models.CharField(db_column='DR_Code', max_length=255, blank=True, null=True)  # Field name made lowercase.
        dr_name = models.CharField(db_column='DR_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        cfo_dr_code = models.CharField(db_column='CFO_DR_Code', max_length=255, blank=True, null=True)  # Field name made lowercase.
        cfo_dr_name = models.CharField(db_column='CFO_DR_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        b_level = models.CharField(db_column='B_Level', max_length=6, blank=True, null=True)  # Field name made lowercase.
        group_name = models.CharField(db_column='Group_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True)  # Field name made lowercase.
        beg_date = models.DateTimeField(db_column='Beg_Date', blank=True, null=True)  # Field name made lowercase.
        end_date = models.DateTimeField(db_column='End_Date', blank=True, null=True)  # Field name made lowercase.
        active = models.IntegerField(db_column='Active', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'QV_DataReduceCFO'

        def __str__(self):
            return str(self.cfo_ntname)

    class QvReportList(models.Model):
        qv_dept_id = models.CharField(db_column='QV_Dept_ID', max_length=100)  # Field name made lowercase.
        report_id = models.CharField(db_column='Report_ID',primary_key=True, max_length=100, serialize=False)  # Field name made lowercase.
        report_name = models.CharField(db_column='Report_Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
        report_name_sc = models.CharField(db_column='Report_Name_SC', max_length=255, blank=True, null=True)  # Field name made lowercase.
        qv_filename = models.CharField(db_column='QV_FileName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        report_access = models.CharField(db_column='Report_Access', max_length=20, blank=True, null=True)  # Field name made lowercase.
        report_group_id = models.IntegerField(db_column='Report_Group_ID', blank=True, null=True)  # Field name made lowercase.
        report_sub_group_id = models.IntegerField(db_column='Report_Sub_Group_ID', blank=True, null=True)  # Field name made lowercase.
        load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True)  # Field name made lowercase.
        approver_fname = models.CharField(db_column='Approver_FName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        approver_lname = models.CharField(db_column='Approver_LName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        approver_ntname = models.CharField(db_column='Approver_NTName', max_length=255, blank=True, null=True)  # Field name made lowercase.
        beg_date = models.DateTimeField(db_column='Beg_Date', blank=True, null=True)  # Field name made lowercase.
        end_date = models.DateTimeField(db_column='End_Date', blank=True, null=True)  # Field name made lowercase.
        active = models.IntegerField(db_column='Active', blank=True, null=True)  # Field name made lowercase.
        approval_id = models.IntegerField(db_column='Approval_ID', blank=True, null=True)  # Field name made lowercase.
        role_based_id = models.IntegerField(db_column='Role_Based_ID', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'QV_Report_List'

    class QVReportAccess(models.Model):
        user_status = models.CharField(db_column='User_Status', max_length = 20)  # Field name made lowercase.
        ntname = models.OneToOneField(settings.AUTH_USER_MODEL,db_column='NTName', max_length=11,primary_key=True, serialize=False)  # Field name made lowercase.
        report_name = models.CharField(db_column='Report_Name', max_length=50, blank=True, null=True)  # Field name made lowercase.
        report_name_sc = models.CharField(db_column='Report_Name_SC', max_length=30, blank=True, null=True)  # Field name made lowercase.
        datareduce_report_code = models.IntegerField(db_column='DataReduce_Report_Code', blank=True, null=True)  # Field name made lowercase.
        role_based_id = models.IntegerField(db_column='Role_Based_ID', blank=True, null=True)  # Field name made lowercase.
        report_id = models.OneToOneField(QvReportList,db_column='Report_ID', max_length=100, blank=True, null=True)  # Field name made lowercase.
        report_group_id = models.IntegerField(db_column='Report_Group_ID', blank=True, null=True)  # Field name made lowercase.
        report_access = models.CharField(db_column='Report_Access', max_length=50, blank=True, null=True)  # Field name made lowercase.
        sr_datareduce_summary_code = models.CharField(db_column='SR_DataReduce_Summary_Code', max_length=10, blank=True, null=True)  # Field name made lowercase.
        sr_datareduce_patient_code = models.CharField(db_column='SR_DataReduce_Patient_Code', max_length=10, blank=True, null=True)  # Field name made lowercase.
        userid = models.IntegerField(db_column='UserID', blank=True, null=True)  # Field name made lowercase.
        user_group_id = models.IntegerField(db_column='User_Group_ID', blank=True, null=True)
        access_level_id = models.IntegerField(db_column='Access_Level_ID', blank=True, null=True)
        active = models.IntegerField(db_column='Active', blank=True, null=True)
        qv_statusid = models.IntegerField(db_column='QV_StatusID', blank=True, null=True)
        employee_status_id = models.IntegerField(db_column='Employee_Status_ID', blank = True, null = True)
        new_user = models.IntegerField(db_column='New_User', blank = True, null = True)
        new_access = models.IntegerField(db_column='New_Access', blank = True, null = True)
        new_report = models.IntegerField(db_column='New_Report', blank = True, null = True)
        changed_row = models.IntegerField(db_column='Changed_Row',blank = True, null = True)
        last_change_date = models.DateTimeField(db_column='Last_Change_Date', blank=True, null=True)  # Field name made lowercase.
        access_beg_date = models.DateTimeField(db_column='Access_Beg_Date', blank=True, null=True)  # Field name made lowercase.
        access_end_date = models.DateTimeField(db_column='Access_End_Date', blank=True, null=True)  # Field name made lowercase.
        report_beg_date = models.DateTimeField(db_column='Report_Beg_Date', blank=True, null=True)  # Field name made lowercase.
        report_end_date = models.DateTimeField(db_column='Report_End_Date', blank=True, null=True)  # Field name made lowercase.
        qv_startdate = models.DateTimeField(db_column='QV_StartDate', blank=True, null=True)  # Field name made lowercase.
        load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True)  # Field name made lowercase.

        class Meta:
            managed = False
            db_table = 'QV_ReportAccess'

class QVFormAccessRequest(models.Model):
    ntname = models.CharField(max_length=11)
    first_name = models.CharField(max_length=40)
    last_name = models.CharField(max_length=140)
    coid = models.CharField(max_length=5)
    facility = models.CharField(max_length=140)
    title = models.CharField(max_length=100)
    report_id = models.CharField(max_length=100)
    report_name_sc = models.CharField(max_length=100, blank=True, null=True)
    accesslevel_id = models.CharField(max_length=100)
    phi = models.BooleanField(default=False)
    access_beg_date = models.DateTimeField(blank=True, null=True)  # Field name made lowercase.
    access_end_date = models.DateTimeField(blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = True
        db_table = 'QV_FormAccessRequest'

    class DjangoMigrations(models.Model):
        app = models.CharField(max_length=255)
        name = models.CharField(max_length=255)
        applied = models.DateTimeField()

        class Meta:
            managed = False
            db_table = 'django_migrations'

    class Sysdiagrams(models.Model):
        name = models.CharField(max_length=128)
        principal_id = models.IntegerField()
        diagram_id = models.AutoField(primary_key=True)
        version = models.IntegerField(blank=True, null=True)
        definition = models.BinaryField(blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'sysdiagrams'
            unique_together = (('principal_id', 'name'),)