Exemplo n.º 1
0
 /** Lists all the contacts of the specifed group */
 @Security.Authenticated(Secured.class)
 public static Result filteredContactsBy(String groupname) {
   User user = getCurrentUser();
   if (!user.isAdmin) return redirect(routes.Application.contacts());
   String btn = groupname;
   return ok(views.html.index.render(Contact.findByGroupname(groupname), contactForm, user, btn));
 }
Exemplo n.º 2
0
 /** Lists all the contacts with yearbook subscription */
 @Security.Authenticated(Secured.class)
 public static Result filteredContactsWithYearbookSubscription() {
   System.out.println("Method: filteredContactsWithYearbookSubscription()");
   User user = getCurrentUser();
   if (!user.isAdmin) return redirect(routes.Application.contacts());
   String btn = "yearbook";
   return ok(views.html.index.render(Contact.withYearbookSubscription(), contactForm, user, btn));
 }
Exemplo n.º 3
0
 /**
  * Lists all the contacts, where the logged in user is owner of the corresponding contact group
  */
 @Security.Authenticated(Secured.class)
 public static Result contacts() {
   User user = getCurrentUser();
   String btn = "all";
   return ok(
       views.html.index.render(
           Contact.findInvolvingGroupOwner(user.email), contactForm, user, btn));
 }
Exemplo n.º 4
0
 @Security.Authenticated(Secured.class)
 public static Result pdfLabels() {
   User user = getCurrentUser();
   PDFiText.generateLabels(Contact.findInvolvingGroupOwner(user.email));
   response().setContentType("application/pdf");
   // response().setHeader("Content-disposition","attachment; filename=labels.pdf");
   return ok(new File("output/labels.pdf"));
 }
Exemplo n.º 5
0
 @Security.Authenticated(Secured.class)
 public static Result download() {
   User user = getCurrentUser();
   if (!user.isAdmin) return redirect(routes.Application.contacts());
   String filename = PoiExcelFileReader.writeFile(Contact.all());
   response().setContentType("application/x-download");
   String headerName = "Content-disposition";
   String headerValue = "attachment; filename=" + filename;
   response().setHeader(headerName, headerValue);
   return ok(new File(filename));
   // return redirect(routes.Application.contacts());
 }
Exemplo n.º 6
0
 @Security.Authenticated(Secured.class)
 public static Result editedContacts() {
   User user = getCurrentUser();
   return ok(views.html.editedContacts.render(Contact.findEditedContacts(), user));
 }
Exemplo n.º 7
0
 /**
  * Deletes the contact by first removing contact from corresponding contact groups and then
  * deleting the contact
  */
 @Security.Authenticated(Secured.class)
 public static Result deleteContact(Long id) {
   Contact.delete(id);
   return redirect(routes.Application.contacts());
 }
Exemplo n.º 8
0
  // TODO change to use Contact.create() method
  @Security.Authenticated(Secured.class)
  public static Result newContact() {

    Form<Contact> filledForm = contactForm.bindFromRequest();

    String name = filledForm.data().get("name");
    String firstName = filledForm.data().get("firstName");
    String title = filledForm.data().get("title");
    String email = filledForm.data().get("email");
    String street = filledForm.data().get("street");
    String appendix1 = filledForm.data().get("appendix1");
    String appendix2 = filledForm.data().get("appendix2");
    String zipcode = filledForm.data().get("zipcode");
    String country = filledForm.data().get("country");
    String city = filledForm.data().get("city");
    String phone = filledForm.data().get("phone");
    String yearbook = filledForm.data().get("yearbookSubscription");
    String memberCategory = filledForm.data().get("memberCategory");
    String membershipSince = filledForm.data().get("membershipSince");

    Contact newContact = new Contact();
    newContact.name = name;
    newContact.firstName = firstName;
    newContact.title = title;
    newContact.email = email;
    newContact.street = street;
    newContact.appendix1 = appendix1;
    newContact.appendix2 = appendix2;
    newContact.zipcode = zipcode;
    newContact.city = city;
    newContact.country = country;
    newContact.phone = phone;

    if (yearbook.equals("true")) newContact.yearbookSubscription = true;
    newContact.memberCategory = memberCategory;

    for (int j = 0; j < ContactGroup.options().size(); j++) {
      String item = "belongsTo[" + j + "]";
      if (filledForm.data().get(item) != null) {
        ContactGroup cg =
            ContactGroup.find.byId((long) Integer.parseInt(filledForm.data().get(item)));
        newContact.belongsTo.add(cg);
      }
    }

    if (newContact.belongsTo.isEmpty())
      filledForm.reject("belongsTo[]", "Keine Sektion ausgewählt");

    // TODO Check fields for errors

    if (filledForm.hasErrors()) System.out.println(filledForm.errors().toString());

    newContact.membershipSince = membershipSince;
    newContact.createdAt = new Timestamp(new Date().getTime());
    newContact.lastEditedAt = newContact.createdAt;
    newContact.save();
    flash("success", "Kontakt " + newContact + " erstellt und gespeichert.");
    return redirect(routes.Application.contacts());
  }
Exemplo n.º 9
0
 /**
  * Generates a pdf file of all the contacts, where the logged in user is owner of the
  * corresponding contact group
  */
 @Security.Authenticated(Secured.class)
 public static Result pdfSummary() {
   User user = getCurrentUser();
   return PDF.ok(views.html.pdfSummary.render(Contact.findInvolvingGroupOwner(user.email)));
 }